Anyone have success w/STRPTIME???

Mauro Cicognini mcicogni at siosistemi.it
Fri Oct 8 09:50:39 EDT 1999


Benjamin Schollnick wrote:

> Can anyone point me in the right direction, re: STRPTIME?
>
> To my knowledge the strptime function(s) are correct below,
> yet under both OS/2 & Win NT, I am getting a attribute error.
>
> I'm assuming it's my fault, but according to the Docs I think
> I've got it setup AOK (TMHK).
>
>                 - Benjamin
>
> import time
> import sys
> from telnetlib import Telnet
>
> print "Connecting to : ", sys.argv[1]
> tn_session = Telnet(sys.argv[1], 13) # Connect to MS Win NT date /
> time
> datetime   = tn_session.read_all()
> tn_session.close()
> print "Server returned: ",datetime
> #timevalue = time.strptime (datetime, '%A, %B, %d, %Y %X')
> timestr    = time.strptime (datetime)
> print timevalue, '   - ', time.asctime(timevalue)
> print
>
> Connecting to :  128.173.14.71
> Server returned:  Tue Oct  5 03:59:56 1999
>
> Traceback (innermost last):
>   File "D:\OS2\PYTHON\WORKING\TIMESERVER\CLIENT13.PY", line 20, in ?
>     timestr    = time.strptime (datetime)
> AttributeError: strptime
>

Ben, strptime() is not supported under Windows. It does say so in the
docs. :(

If you're interested, I've written a str2time() which I'm pretty much
satisfacted with, that does some nice RE processing and a couple crude
hacks to get what I want in a Python format. It extracts a date from
many general-format strings; if you need to, changing the RE will allow
you to parse even more formats. I can send you the source if you wish.

Also, a coworker of mine has found a strptime() written in Python (which
will work on Windows, too) that does all that the standard strptime()
does, and more.

Cheers
Mauro

-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcicogni.vcf
Type: text/x-vcard
Size: 566 bytes
Desc: Card for Mauro Cicognini
URL: <http://mail.python.org/pipermail/python-list/attachments/19991008/4296e29e/attachment.vcf>


More information about the Python-list mailing list