I read up a few RFCs and ISO specifications. In particular, RFC2822: Internet Message Format, and RFC3339: Date and Time on the Internet: Timestamps, which summarises ISO8601: An internet standard for date and time (Wikipedia link). Below is a summary of what these specifications state.
RFC2822 lists two date formats, in sections 3.3 and 4.3. 3.3 is current while 4.3 is obsolete. RFC3339 lists a third date format based on ISO8601. All these specifications are for date-time representations for use on the Internet.
- RFC3339:
- 2008-09-23T17:39:44-07:00
- RFC2822:
- Tue, 23 Sep 2008 17:39:44 -0700
- (obsolete) Tue, 23 Sep 2008 17:39:44 PDT (might also include 2 digit year)
Z
, indicating Zulu time (UTC+0000).Additionally, RFC2822 lists 10 codes in the obsolete: UT, GMT, EST, EDT, CST, CDT, MST, MDT, PST, PDT. Military time zones (A-Z) are also included in the obsolete list. While other time zone codes have been used by various implementations, they are not defined by a common specification, and SHOULD NOT be used.
My tests with the
Date.toString()
method have shown the following:Internet Explorer returns the time zone code for the eight US time zones listed in section 4.3. of RFC2822, and the offset for all other time zones using the
UTC+/-HHMM
format. The offset is NOT included for the eight US time zones specified above. This is in line with RFC822, but not 2822, which obsoletes 822.Examples:
- PST:
- Thu Sep 18 16:47:36 PDT 2008
- IST:
- Fri Sep 19 10:11:38 UTC+0530 2008
Firefox returns the offset for all time zones, and a time zone string in parentheses for some time zones. The string is different on different platforms:
- Windows:
- full timezone name, ie, Pacific Standard Time
- Linux & Mac OS X:
- timezone code, ie, PST
examples:
- Windows/Taiwan
- Tue Sep 23 2008 10:14:10 GMT+0800
- Windows/India
- Tue Sep 23 2008 09:42:49 GMT+0530 (India Standard Time)
- Mac OS X/US West Coast
- Tue Sep 23 2008 17:57:04 GMT-0700 (PDT)
- Linux/India
- Tue Sep 23 2008 09:42:49 GMT+0530 (IST)
Safari matches the results for Firefox on Mac OS X.
Both Safari and Firefox match the specification by including the offset. The time zone code that they return is considered auxiliary information for display purpose only.
Opera consistently uses the
UTC+/-HHMM
format on all platforms, and never includes a time zone code. This is probably the strictest adherence to the specification.So, what does all this mean? Well, to me, it means that I shouldn't spend any more time searching for a browser independent way to pull out the time zone code. It also means that
strftime
does not provide an easy way to print out an RFC3339 date with the colon in the time zone offset, but we'll figure something out for that :)Finally, a bit of trivia...
Standard time in the Netherlands was exactly 19 minutes and 32.13 seconds ahead of UTC by law from 1909-05-01 through 1937-06-30. This time zone cannot be represented exactly using the HH:MM format.
Short URL: http://tr.im/dateformats
0 comments :
Post a Comment