[Zope3-dev] datetimeutils: add localize datetime?

Gustavo Niemeyer niemeyer at conectiva.com
Tue Feb 1 21:57:39 EST 2005


> > > It's not just guessing-based. It has documented behaviour [1] and tests,
> > > and the parsing is pluggable [2], which I think it's a must for any such
> > > functionality.
> >
> > Indeed, it's almost not guessing. You may tell what dates to expect, and
> > which order is the expected one. OTOH, right now, it will try a different
> > order if the given one fails. This is wrong. An exception should be
> > issued in these cases, and that's how the next release will behave.
> 
> Okay, so based on Sidnei's and Gustavo's comments I can safely say that 
> zope.i18n.format does provide this functionality as well using already the 
> ICU data files. The parser and formatter there is based on patterns. A 
> high-level function could simply look through a set of specified pattern to 
> find a match.

Just to make sure you understand what I was talking about, the
"what dates to expect" referred to the order in which an ambiguous
date is provided, like how to interpret 01/01/01. The parsing
mechanism does provide a smarter parser than simple pattern
based alternatives.

If you're really looking for that kind of functionality, please
have a look at the code in dateutil before going on.

Here are some examples of parsed dates:

2003 10:36:28 BRST 25 Sep Thu
Thu Sep 25 10:36:28 BRST 2003
Thu, 25 Sep 2003 10:49:41 -0300
Tuesday, April 12, 1952 AD 3:30:42pm PST
November 5, 1994, 8:15:30 am EST
2003-09-25T10:49:41.5-03:00
20030925T104941.5-0300
July 4, 1976
2003 Sep 25
25-Sep-2003
Sep-25-2003
2003-Sep-25
2003.Sep.25
2003/Sep/25
10h36m28.5s

-- 
Gustavo Niemeyer
http://niemeyer.net


More information about the Zope3-dev mailing list