Dates: ISO 8601
david at openpartnership.net
Wed Mar 7 11:59:16 CST 2007
Hi Klaus - I was just thinking someone out there must have a ready made
handler as it is real common format on the internet. I've given a go below -
I include some info for reference:
A common use could be [YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]±[hh]:[mm].
> "1981-04-05T14:30:30-05:00", for example.
Two good references:
So it's basically dateitems with dashes a "T" in the middle and a "Z" or bit
from the internet time (UTC) at the end - not too clear on the timezone
> If the time is in UTC<http://en.wikipedia.org/wiki/Coordinated_Universal_Time>,
> it is very easy to show this. Simply add a 'Z' directly after the time,
> without a space. "09:30 UTC" is therefore represented as "09:30Z" or
> "0930Z". "14:45:15 UTC" would be "14:45:15Z" or "144515Z".
> ] Other time zones
> Other time zones are specified by their *offset* from UTC, in the format
> ±[hh]:[mm], ±[hh][mm] or ±[hh]. So if the time being described is one hour
> ahead of UTC (such as the time in Berlin<http://en.wikipedia.org/wiki/Berlin>during the winter) the offset would be "+01:00", "+0100" or simply "+01".
> This is appended to the time in the same way that 'Z' was above. Note that
> the offset is the actual offset from UTC, and does not include any
> information on daylight saving time<http://en.wikipedia.org/wiki/Daylight_saving_time>.
> Times expressed in local time for a user in Chicago<http://en.wikipedia.org/wiki/Chicago>would be "-06:00" for the winter (Central
> Standard Time <http://en.wikipedia.org/wiki/Central_Standard_Time_Zone>)
> and "-05:00" for the summer (Central Daylight Time<http://en.wikipedia.org/wiki/Central_Daylight_Time_Zone>).
> The following times all refer to the same moment: "18:30Z", "22:30+04",
> "1130-0700" and "15:00-03:30".
So this seems to work:
function date_Construct8601 someDate
-- ie "1981-04-05T14:30:30-05:00"
convert someDate to internet date
put word -1 of somedate into utcOffset
convert someDate to dateItems
put item 1 to 3 of someDate into dateBit
replace comma with "-" in dateBit
put item 3 to 6 of somedate into timeBit
replace comma with ":" in timeBit
return dateBit & "T" & timeBit & utcOffset
More information about the use-livecode