Yenya's World

Thu, 24 Aug 2006

W3C Date and Time

Apparently W3C has defined its own date and time format, incompatible with anything else. And what is worse, they use the "+HH:MM" format for the timezone offset, which means W3C time format cannot be formated with standard library's strftime(3) function.

POSIX (and ISO C99) defines the "%Z" fromat string for the textual name of the time zone only. GNU libc (and Perl as well) provide an extension "%z" which leads to "+HHMM" format, suitable for formating RFC822-style time zone offsets. But W3C had to invite yet another format, this time with colon between hours and minutes. Why the standardization organizations cannot reuse an existing practice, and have always to create something different and difficult to produce with standard tools?

CPAN has DateTime::Format::W3CDTF, so at least the Perl side is safe (altough I have not tried it yet, and from their docs it is not clear how they handle the time zone at all). But it uses the DateTime object as a time source, instead of the return value of localtime() or gmtime().

Section: /computers (RSS feed) | Permanent link | 5 writebacks

5 replies for this story:

Adelton wrote:

Why not show the time in GMT/Zulu?

Yenya wrote: GMT

Good idea, altough the result isn't both machine and human readable then.

Adelton wrote: GMT

Well, Date:, Expires:, and Last-Modified: seem to be delivered in GMT time zone anyway (tested against aisa's Apache and against Google).

Ken Allan wrote:

Actually, ISO 8601 is the standard for date/time representation, and has been since 1988. The DateTime format that W3C adopted has been around for well over 25 years, and is recognized as the standard way for representing dates and time in computerized systems. Here is the exact text for the ISO 8601:1988 standard: I'm not trying to be pedantic here, merely pointing out that the W3C (as usual) have done their research and done things the "proper" way, convention be damned! One may of course still argue that perhaps "convention be damned!" may not be the best way to do these things. Anyhow, enough ranting and best of wishes.

Yenya wrote: ISO 8601

OK, point taken. The problem is then conflicting standards only (ISO 8601/W3C versus ANSI/ISO/POSIX strftime()). Thanks for the explanation

Reply to this story:

URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Key image: key image (valid for an hour only)
Key value: (to verify you are not a bot)


Yenya's World: Linux and beyond - Yenya's blog.


RSS feed

Jan "Yenya" Kasprzak

The main page of this blog



Blog roll:

alphabetically :-)