The Strings of Time

posted by Pete Thomas in Date & Time, Zoho Creator
  • 311 views
  • 2 comments

Goal:

Marshal a string representing the current time in various formats.

Ideas:

The example application demonstrates 7 variations on creating a string representation of the current time, along with Deluge code examples:

  1. PT(UTC -7/-8) Stamp: Pacific time zone timestamp
  2. UTC Stamp: Coordinated Universal timestamp
  3. PT: Pacific time zone time
  4. UTC: Coordinated Universal time
  5. PT Date: Pacific time zone date
  6. UTC Date: Coordinated Universal date
  7. Epoch: Seconds elapsed since Jan 1, 1970

You can paste the appropriate script fragment into your own ZC application to store or display the desired format.

Blabber:

Until Zoho Creator supports time zone configuration and controls, we either need to be content with date-formatted timestamp strings that are relative to the current Pacific time zone (PST or PDT, depending on the calendar date) or roll our own code in Deluge to represent other formats.

clockRemember that when you store the value of zoho.currenttime in formula fields within your application, ZC is actually storing a value to the millisecond level of precision. It’s only when you try and stringify the value or ask the ZC user interface or one of the export formats to display it that the result will be represented as a date in the current Pacific time.

By having the UTC option and the option to display time as well as date, you can create applications that store the precise value of zoho.currenttime in a formula field but keep another text, etc. field handy to store a value suitable for reading by humans.

STRINGS ATTACHED

Keep in mind that when storing a string formatted to one of the UTC formats, you can’t later come back to it, stuff it into a date field, and expect to reliably use any of Deluge’s built-in date functions or Date & Time Operators. As mentioned earlier those all currently assume you’re supplying and expecting values relative to the Pacific time zone.

Related Links:

Date Variables, Time Stamp On Orders.

ZC Weirdness (potential bugs in the system):

Here’s a quick rundown of unexpected issues encountered during this exercise:

VANISHING PARENTHESES

Currently there seems to be an issue with the way ZC’s graphical editor saves Deluge parentheses. With regard to the script used to generate the tutorial, after it was saved ZC seemed to try to optimize by removing allegedly unnecessary parens but when editing and saving changes to that optimized version ZC would display errors related to missing parens. I’ve published the script apart from the ZC installation with all the necessary parens intact in case you’d like a pristine copy.

VANISHING ENTITIES

If you try to upload a script containing HTML entities, the ZC uploader will translate them into the characters they represent. This can cause problems when including text like:

foobar = "This sentence has "quoted text" in it.";

But if you paste the script into ZC instead of uploading it, this doesn’t seem to be a problem. Not a big deal, really.

PLAINTEXT VARIABLE NAMES

It seems the ZC graphical interface does not currently let you choose the variable name for form fields of type plaintext. No matter what label name I tried to give them, they reset back to the default naming scheme of “plain”, “plain1″, “plain111″, etc. Again, not a big deal. If you’re a stickler for such things you can save the Deluge script as text, rename the fields, and recreate the application by pasting in a fresh copy.

photo © Darren Hester for openphoto.net CC:Attribution-NonCommercial

  1. Hyther Nizam INDIA Said,

    Just stumbled upon this blog. You have made my day, Pete.

    We are glad to have you in zoho creator community. Pls continue your exploration, innovation and fun with creator.. I have asked my team to read your blogs and take up the suggestions and ideas

    Hyther Nizam
    Product manager,
    Zoho Creator

  2. petet UNITED STATES Said,

    Thanks, Hyther. If nothing else I hope this blog can serve as a place to store the occasional idea or solution that might otherwise be buried in the Zoho Discussions Creator forum.

    Also I look forward to including any contributions or feedback from your team. If they are making time to spend here at LoZC I’ll try to make it worth their effort.

    Regards,

    Pete

Add A Comment