Converting a string to the most probable type

rockingred willsteve2003 at yahoo.ca
Fri Mar 7 12:19:18 EST 2008


Dates can be a pain.  I wrote my own date program, simply because
there are so many different ways to write a date:

Mar 8, 2008
March 8th, 08
03/08/08
03-08-2008

And so on and so forth.  The tricky bit is how to tell the difference
between Day, Month and Year.

I wrote a program to check the format used for a date.  I assumed that
any 4 digits together in a single group were the year.  Then I had a
list of Months, with the first 3 characters of each and compared that
to the field being checked, if found, then that was the month.  Then I
assumed any number greater than 12 was a day.  If I couldn't match
those criteria I assumed Month Day Year (the standard at the company I
worked for).



More information about the Python-list mailing list