time.strptime intolerant on weekday string length?

R

Robert

A certain DAV server reports a time stamp as "Tues, 30 Aug 2005 20:48:31"
( but not "Tue, ..." as usual)

This produces the error below.
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\lib\_strptime.py", line 425, in strptime
raise ValueError("time data did not match format: data=%s fmt=%s" %
ValueError: time data did not match format: data=Tues, 30 Aug 2005 20:48:31
fmt=%a, %d %b %Y %H:%M:%S

I also don't see how to alter the pattern for strptime to be tolerante for
more long weekday strings?
Any ideas?
Shouldn't it be possible to insert real regexp-like stuff in the pattern?

Robert
 
F

Fredrik Lundh

Robert said:
A certain DAV server reports a time stamp as "Tues, 30 Aug 2005 20:48:31"
( but not "Tue, ..." as usual)
I also don't see how to alter the pattern for strptime to be tolerante for
more long weekday strings?
Any ideas?

why bother parsing the day name at all? (just split the string at the first
command and use strptime on the rest)
Shouldn't it be possible to insert real regexp-like stuff in the pattern?

if you need an RE, use an RE. no need to use strptime if you don't what
that behaviour (to convert the RE result to a time value, use time.mktime,
calender.timegm, or the datetime module, depending on what you want)

</F>
 
F

Fredrik Lundh

why bother parsing the day name at all? (just split the string at the first
command and use strptime on the rest)

msg = msg.replace("command", "comma")

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top