Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Emacs Lisp: Writing a Date Time String Parsing Function

49 views
Skip to first unread message

Xah Lee

unread,
Sep 21, 2011, 7:28:43 PM9/21/11
to
〈Emacs Lisp: Writing a Date Time String Parsing Function〉
http://xahlee.org/emacs/elisp_parse_time.html


On Sep 21, 4:48 am, "Oleksandr Gavenko (gavenkoa)"
<gave...@bifit.com.ua> wrote:
> 04.09.2011 11:29, Xah Lee пишет:> Write a elisp function. The function will take a string argument that's any of common date time format, e.g.
>
> >      Fri, 2 Sep 2011 11:14:11 +0200 (unixy)
>
>  >      09/02/2011 (USA)
>  >      Sep 2, 2011
>  >      2 Sep, 2011
>  >      2 September, 2011
> Facking USA time format... Why people like it???? STOOOPPP!!!
>
>    format-time-string is a built-in function in `C source code'.
>    ...
>    %b and %h are the locale's abbreviated month name, %B the full name.
>
> So if you use:
>
>    (format-time-string "%d %b %Y %H:%M:%S %z"  ...)
>
> like this done in
>
> http://bazaar.launchpad.net/~hexmode/weblogger-el/trunk/view/head:/we...
>
> you can not parse back by 'parse-time-string' as month name is 'Март'.
>
>
>
> > and output a canonical form 2011-09-02.
>
> This time specification come from ISO 8601 3ed:
>
> (parse-time-string "1985-04-12T10:15:30+04:00") ; fail
> (parse-time-string "19850412T101530+0400")  ; fail
>
> Emacs understand only (space instead 'T', no timezone):
>
> (parse-time-string "1985-04-12 10:15:30") ; OK

as far as i know, using space instead of T is not part of the ISO 8601
standard. Or did they change?

i know that there are standards based on ISO 8601 that allows space. I
think it's part of some XML. Anyone know which standard is it?

Xah

Antony

unread,
Sep 22, 2011, 10:20:36 AM9/22/11
to
On 9/21/2011 4:28 PM, Xah Lee wrote:
>> Emacs understand only (space instead 'T', no timezone):
>>
>> (parse-time-string "1985-04-12 10:15:30") ; OK
>
> as far as i know, using space instead of T is not part of the ISO 8601
> standard. Or did they change?
>
> i know that there are standards based on ISO 8601 that allows space. I
> think it's part of some XML. Anyone know which standard is it?
I just happen to stumble on this today
http://diveintohtml5.org/semantics.html#time-element
Although I am sure that's not the origin of the T thing

-Antony

Oleksandr Gavenko (aka gavenkoa)

unread,
Sep 26, 2011, 4:52:15 PM9/26/11
to
I know, Xah )) Look:

Network Working Group G.
Klyne
Request for Comments: 3339 Clearswift
Corporation
Category: Standards Track C.
Newman
Sun
Microsystems
July
2002

Date and Time on the Internet: Timestamps

In "Internet Date/Time Format" section written:

NOTE: ISO 8601 defines date and time separated by "T".
Applications using this syntax may choose, for the sake of
readability, to specify a full-date and full-time separated by
(say) a space character.

Oleksandr Gavenko (aka gavenkoa)

unread,
Sep 26, 2011, 5:01:18 PM9/26/11
to
On 22 сен, 02:28, Xah Lee <xah...@gmail.com> wrote:
> as far as i know, using space instead of T is not part of the ISO 8601
> standard. Or did they change?
>
I look into ISO_8601-2004_E.pdf and found:

Unless explicitly allowed by this International Standard the
character
“space” shall not be used in the representations.

and all other occurrence of 'space' keyword with 'without' word.

Xah Lee

unread,
Sep 26, 2011, 8:11:01 PM9/26/11
to
Xah Lee wrote:
> as far as i know, using space instead of T is not part of the ISO 8601
> standard. Or did they change?

> i know that there are standards based on ISO 8601 that allows space. I
> think it's part of some XML. Anyone know which standard is it?

Oleksandr Gavenko (aka gavenkoa) <gaven...@gmail.com> wrote:
> http://tools.ietf.org/html/rfc3339

> In "Internet Date/Time Format" section written:
>
>       NOTE: ISO 8601 defines date and time separated by "T".
>       Applications using this syntax may choose, for the sake of
>       readability, to specify a full-date and full-time separated by
>       (say) a space character.

Thanks.

Xah
0 new messages