emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can `format-time-string' produce full/extended ISO 8601 times?


From: Juri Linkov
Subject: Re: Can `format-time-string' produce full/extended ISO 8601 times?
Date: Mon, 03 Aug 2009 02:52:49 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (x86_64-pc-linux-gnu)

> Does `format-time-string' produce full/extended ISO 8601 format times?
>
> -
> Docstring of `format-time-string' states:
>
>  "For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z"."
>
> As best I can gather this is _not_ a 'full' ISO 8601 time string format.
> Specifically, section 4.2.5.1-2 of ISO 8601:2004(E)
>
> --
> 4.2.5.1 Difference between local time and UTC of day
>
> Basic format:      ±hhmm             Example: +0100
>                      ±hh                      +01
>
> Extended format:   ±hh:mm            Example: +01:00
>
> --
> 4.2.5.2 Local time and the difference from UTC
>
> Basic format:      hhmmss±hhmm       Example: 152746+0100
>                                               152746-0500
>                    hhmmss±hh                  152746+01
>                                               152746-05
>
> Extended format:   hh:mm:ss±hh:mm    Example: 15:27:46+01:00
>                                               15:27:46-05:00
>                    hh:mm:ss±hh                15:27:46+01
>                                               15:27:46-05
>
> ---
> I am referencing from the .pdf available here:
> (URL 
> `http://isotc.iso.org/livelink/livelink/4021199/ISO_8601_2004_E.zip?func=doc.Fetch&nodeid=4021199')
>
> ----
> Is it possible to format the UTC offset/ZONE with a colon per the
> Extended format above?
>
> On a w32 system I'm get these results:
>
> (format-time-string "%Y-%m-%dT%T%z")
> ;=>"2009-07-30T18:04:56-0400"
>
> (format-time-string "%Y-%m-%dT%T,%u%z")
> ;=>"2009-07-30T18:04:36,4-0400"
>
> (format-time-string "%Y-%m-%dT%T,%u%z" nil t)
> "2009-07-30T22:05:47,4+0000Z"
>
> (format-time-string "%Y-%m-%dT%T,%u%z" (current-time) t)
> ;=>"2009-07-30T22:06:10,4+0000"

Do you complain that `format-time-string' uses the extended format for
date/time and the basic format for time zone?  Well, RFC 3339 says:

  Due to ambiguities in ISO 8601, some interpretations had to
  be made.  First, ISO 8601 is not clear if mixtures of basic and
  extended format are permissible.

And provides a grammar that permits mixtures:

  time-numoffset    = ("+" / "-") time-hour [[":"] time-minute]

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]