The Strings of Time
July 19, 2007Goal:
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:
- PT(UTC -7/-8) Stamp: Pacific time zone timestamp
- UTC Stamp: Coordinated Universal timestamp
- PT: Pacific time zone time
- UTC: Coordinated Universal time
- PT Date: Pacific time zone date
- UTC Date: Coordinated Universal date
- 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.
Remember 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


