PEP 321: Date/Time Parsing and Formatting
Gerrit Holl
gerrit at nl.linux.org
Tue Nov 18 08:25:30 EST 2003
Paul Moore wrote:
> Gerrit Holl <gerrit at nl.linux.org> writes:
> > 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 assume you're aware of Gustavo Niemeyer's DateUtil module
> (https://moin.conectiva.com.br/DateUtil)?
I was not, actually. Thanks for the link.
It looks like a very comprehensive library!
The example actually calculates the next time I'm having birthday on
friday the 13th :)
> [After reading through this PEP and commenting, I'd say that my
> preference (which may not be Gustavo's!) would be to add dateutil to
> the standard library, with the following changes/additions:
Sounds like a good idea.
>
> > * Formats commonly written by humans such as the American
> > "MM/DD/YYYY", the European "YYYY/MM/DD", and variants such as
> > "DD-Month-YYYY".
>
> UK format DD/MM/YYYY is worth adding (in my UK-based opinion :-)) But
> you can get all of these via strptime (wrapped to return a datetime
> value).
I don't think so. One you just as well add the German "D.M.YY", and many
others.
> > 3) Add a separate module (possible names: date, date_parse, parse_date)
> > or subpackage (possible names: datetime.parser) containing parsing
> > functions::
> >
> > import datetime
> > d = datetime.parser.parse_iso8601("2003-09-15T10:34:54")
>
> I'd go for this option.
It depends on how comprehensive it would be. Gustavo's DateUtil module
does a lot more than this PEP suggests. For an implementation of this
PEP, I think a seperate module is not necessary. For DateUtil, I think
it is.
yours,
Gerrit.
--
185. If a man adopt a child and to his name as son, and rear him, this
grown son can not be demanded back again.
-- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
http://www.sp.nl/
More information about the Python-list
mailing list