By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

time.strptime intolerant on weekday string length?

P: n/a
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.
time.strptime("Tue, 30 Aug 2005 20:48:31","%a, %d %b %Y %H:%M:%S") (2005, 8, 30, 20, 48, 31, 1, 242, -1) time.strptime("Tues, 30 Aug 2005 20:48:31","%a, %d %b %Y %H:%M:%S") 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
Sep 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Robert wrote:
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>

Sep 13 '05 #2

P: n/a
> 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>

Sep 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.