strptime - dates formatted differently on different computers

Michael Torrie torriem at
Tue Dec 11 09:23:21 CET 2012

On 12/11/2012 01:08 AM, Chris Angelico wrote:
> There are a LOT more date formats than those used in the USA. The most
> obvious trio is American MDY, European DMY, Japanese YMD, but there
> are plenty more to deal with. Have fun.

For the record I didn't write the module, so I don't care whether or not
I have fun or not.  The module is simply there, and I've found it quite
useful for parsing free-form dates as arguments passed to my program.
While what you say is correct--and the parser can be given hints about
what order to expect numeric dates--if you read the OP's question, he
really is mainly looking for a flexible date parser that can handle /
instead of - as a separator.  And going by his example, the order is the
same, so if he can parse one he can parse the other.  This is exactly
the kind of thing the dateutil.parser module works for.  That's why I
suggested it.  Sure he needs to always be aware of the order, but I have
to assume that since his strptime had a specific order, he has a reason
for assuming that order.  If he wasn't he is now, of course.

More information about the Python-list mailing list