PEP 321: Date/Time Parsing and Formatting

John Roth newsgroups at jhrothjr.com
Mon Nov 17 20:19:12 EST 2003


"Bengt Richter" <bokr at oz.net> wrote in message
news:bpbq7h$nf2$0 at 216.39.172.122...
> On Mon, 17 Nov 2003 17:59:24 -0500, "John Roth" <newsgroups at jhrothjr.com>
wrote:
>
> >
> >"Gerrit Holl" <gerrit at nl.linux.org> wrote in message
> >news:mailman.803.1069091744.702.python-list at python.org...
> >> Hi,
> >>
> >> PEP 321 reads:
> >> > Python 2.3 added a number of simple date and time types in the
> >> > ``datetime`` module.  There's no support for parsing strings in
various
> >> > formats and returning a corresponding instance of one of the types.
> >> > This PEP proposes adding a family of predefined parsing function for
> >> > several commonly used date and time formats, and a facility for
generic
> >> > parsing.
> >>
> >> I was recently surprised by this fact. I don't know why there isn't
> >> such a function/method. In my opinion, it isn't a question of whether
> >> to add them or not, but how.
> >>
> >> > Input Formats
> >> > =======================
> >> >
> >> > Useful formats to support include:
> >> >
> >> > * `ISO8601`_
> >> > * ARPA/`RFC2822`_
> >> > * `ctime`_
> >> > * Formats commonly written by humans such as the American
> >> >   "MM/DD/YYYY", the European "YYYY/MM/DD", and variants such as
> >> >   "DD-Month-YYYY".
> >
> >I didn't notice this going past the first time: YYYY/MM/DD is the
>                                                               ^--UIAM,
NOT!
> >ISO standard format, DD/MM/YYYY is the European variant to
> >the American MM/DD/YYYY.
>
> I thought '-' delimiters were standard, and the yyyy-mm-dd ordering
standard,
> and anything else a variant.

I usually don't worry about the delimiters, but you're probably right. The
ISO
standard is yyyy-mm-dd, however, the *customary* usage in most of the
world is dd-mm-yyyy, and in the US it's mm-dd-yyyy. In fact, you'd have
difficulty finding anyone around these parts who knows that year first
is a standard, let alone *the* international standard. And I very seldom
see it on the web sites I visit, regardless of country of origin.

John Roth
>
> See
>     http://www.w3.org/TR/NOTE-datetime
> or
>     http://www.iso.ch/iso/en/prods-services/popstds/datesandtime.html
>
> [...]
>
> Regards,
> Bengt Richter






More information about the Python-list mailing list