Intelligent strptime?

Gerrit Holl gerrit.holl at pobox.com
Wed Nov 10 14:40:23 EST 1999


Charles G Waldman wrote:
> Gerrit Holl writes:
>  > 
>  > Does there exist an intelligent strptime? "26/11/99", for example, can _only_
>  > mean the 26th November of this year, and the chance that "14:11:12" means
>  > 14 november 1912 is very small. Is there a module/function that guesses the
>  > format? There isn't doubt very often, only for 12/11/99, US is 11 december,
>  > Europe is 12 November (isn't it?).
> 
> I think that there's an ambuguity between US-style MM/DD and
> European-style DD/MM whenever the day of the month is 12 or less.   Of 
> course when DD==MM then the ambuguity doesn't matter (e.g. 3/3/99).
> But that still leaves 11 days in each month which have this ambiguity, 
> which comes to 132 days per year.  So, given a 365-day year, 36% of
> the dates are ambiguous, which doesn't make "guessing" look like a
> very attractive option to me.

It could return a tuple or something then. But if I want people to choose:
either input "Nov, 23" or "12/6/99" or "1 December 2000", I don't want to
check too much. There are much date processing programs (date, I think) that
do this intelligent. You could also let the above think depend on the timezone,
if it's an american timezone, take the american way, else, take the
european way. But returning a tuple on 132 days seems better to me.

regards,
Gerrit.
-- 
linuxgames.nl.linux.org	 All about games on Linux in Dutch (under construction).
www.nl.linux.org	       The Dutch resource for Dutch Linux documentation.
www.nl.linux.org/discoverb		    Learn foreign words and definitions.
www.nl.linux.org/~gerrit/asperger	 I'm an Asperger, go here for more info.
www.nl.linux.org/~gerrit			    About me and pictures of me.




More information about the Python-list mailing list