[Zope3-dev] date parsing: explicit is better
Steve Alexander
steve@cat-box.net
Fri, 22 Nov 2002 15:11:10 +0000
In Zope 2, the string '05-11-2002' is parsed by DateTime into the 11th
May 2002.
This is the US month-day-year convention for writing dates, used
thoughout the US, except when the ISO standard of 2002-05-11 is used,
and except on immigration forms, where I guess the immigration service
discovered that non-Americans find the American format confusing.
The European convention for writing dates is to parse the string
'05-11-2002' as 5th November 2002. The day-month-year convention.
Zope is widely used in Europe. European zope developers are often
confused by the Zope 2 behaviour, especially when the dates they are
developing with are ones which parse correctly either way around.
I propose that the date parsing module that comes with Zope 3 should
raise an exception if it is given an ambiguous date specification. That
is, it should not accept day-month-year nor month-day-year, but only
year-month-day.
Adapters should be provided for European and American date parsing.
(Or perhaps a method argument. Although, if it is a method argument, if
the argument is omitted, it should not assume one or the other.)
This would make a programmer's intentions explicit, and would not
confuse Americans reading European code or vice versa.
--
Steve Alexander