Various strings to dates.

wes weston wweston at att.net
Fri Jan 23 22:49:32 CET 2004


Amy,
    I hope there is a better way but, if you go here:

http://www.python.org/doc/current/lib/datetime-date.html

The new datetime module may help. This and the time mod
should get you where you want to go.

list     = strdate.split(", ")
daystr   = list[0]
daynum   = int(list[1])
monthstr = list[2]
year     = int(list[3])
#funct to get a month int is needed

d = datetime.Date(y,m,d)

wes

---------------------------------------

Amy G wrote:
> I have seen something about this beofore on this forum, but my google search
> didn't come up with the answer I am looking for.
> 
> I have a list of tuples.  Each tuple is in the following format:
> 
> ("data", "moredata", "evenmoredata", "date string")
> 
> The date string is my concern.  This is the date stamp from an email.
> The problem is that I have a whole bunch of variations when it comes to the
> format that the date string is in.  For example I could have the following
> two tuples:
> 
> ("data", "moredata", "evenmoredata", "Fri, 23 Jan 2004 00:06:15")
> ("data", "moredata", "evenmoredata", "Thursday, 22 January 2004 03:15:06")
> 
> I know there is some way to use the date string from each of these to get a
> date usable by python, but I cannot figure it out.
> I was trying to use time.strptime but have been unsuccesful thus far.
> 
> Any help is appreciated.
> 
> 




More information about the Python-list mailing list