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: MON KEY
Subject: Re: Can `format-time-string' produce full/extended ISO 8601 times?
Date: Thu, 6 Aug 2009 14:39:20 -0400

2009/8/2 Juri Linkov <address@hidden>:
>> Does `format-time-string' produce full/extended ISO 8601 format times?
>
> 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:

Wasn't a complaint at all.

FTMP `format-time-string' does _exactly_ what one would expect.

To reiterate, the gist of my query is this:

  Is it possible to format the UTC offset/ZONE with a colon per the
'Extended format?

>From what I am able to gather the "%z" of the `format-time-string'
spec doesn't produce a colon delimited UTC-offset/ZONE and provides
only for production of the time-numoffset as:

+/-time-hourtime-minute -> +/- hhmm  -> "-0500"

To the extent that the standard is unclear/ambiguous, stating that:

'For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z".'

can not be correct as there is no 'full ISO 8601' format; e.g. the
following is not 'full' but only full-ish :)

(format-time-string "%Y-%m-%dT%T%z")
=> "2009-08-06T13:50:23-0400" ; On a w32 system.

This would _appear_ to stand in contrast the referenced section of the
standard, e.g. '4.2.5.1-2 of ISO 8601:2004(E)' which permits at least
two other possible variations:

The 'Basic format' is one of these:

  +/-time-hour            ->  +/-hh     -> "-05"
  +/-time-hourtime-minute ->  +/- hhmm  -> "-0500"

With the later variant of the basic format considered _more_ specific
than the former.

My specific concern is w/re to the standards proviso for an extended
format such that:

  +/-time-hour:time-minute ->  +/- hh:mm  -> "-05:00"

>
>  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]
>

As you point out, _here_ the standard is ambiguous as to canonical
preference and permissible deviations. That said - as I read the
standard - it would seem that when in doubt the Extended (and where
applicable delimited) format is generally considered _more_ preferable
than the Basic. Regardless, apropos my initial query, whether this
particular reading is correct need not be of concern.  Rather, I
remain curious to know if it is _possible_ to produce a time string
with a UTC/ZONE portion having the format:

 +/-time-hour:time-minute ->  +/- hh:mm  -> "-05:00"  ; _with_ colon delimiter

Specifically, I am inquiring whether such production is possible with
the current existing `format-time-string' (sans extension).

If so, this should be be made clear in the docs. If not, the docs
should be modified to indicate:

'For example, to produce an ISO 8601 compliant format, use "%Y-%m-%dT%T%z".'

as contrasted with the current:

'For example, to produce full ISO 8601 format, use "%Y-%m-%dT%T%z".'

Further, if a production of UTZ/Zone colon delimited timestring is not
possible and it does not pose significant runtime/source overhead I
would propose consideration for inclusion of an additional "%Z" format
spec to `format-time-string'.

> Juri Linkov

s_P




reply via email to

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