time.strptime() not supported in windows? what the.....

Daley, Mark W mark.w.daley at intel.com
Mon Aug 7 14:54:31 EDT 2000


When I went looking for this, someone provided me with a solution they had
already written.  The .pyc file is attached, since the .py file just
contains the following text:


""" strptime version 1.3, Time-stamp: <96/09/23 21:22:24 flognat>
               The reverse of strftime.

    Copyright (C) 1996 Andy Eskilsson, flognat at fukt.hk-r.se

    This is free software; unrestricted redistribution is allowed under the
    terms of the GPL.  For full details of the license conditions of this
    software, see the GNU General Public License.

    And here comes the documentation:

    Throw a string and a format specification at strptime and if everything
    is ok you will get a tuple containing 9 items that are compatible with
    pythons time-module.

    interface:
       strptime(inputstring, formatstring)

       Little errorchecking... so you'd better now what you are doing.

    example:
       from strptime import *
       mktime(strptime("26/6 1973", "%d/%m %Y"))

    And voila you have the second when the author of this function was born.

    The supported format identifiers are:
        %a weekday in short text-form, e.g. Mon
	%A weekday in long text-form, e.g. Monday
	%b month in short text-form, e.g. Jul
	%B month in long text-form e.g. July
	%c the format specified by DateAndTimeRepresentation
	%d the day in month in numeric form, e.g. 24
	%H hour in 24 hour form
	%j julian day (day of year)
	%m month in numeric format
	%M minute
	%S second
	%T Time in '%H:%M:%S'-format
	%w weekday, 0=monday
	%x date in format represented by DateRepresentation
	%X time in format represented by TimeRepresentation
	%y year in short form
	%Y year in long form
	%% %-sign

    I have done some thinking here (*REALLY*) and it is possible to
configure
    this module so it uses other languages by adding their names to the
    dictionaries first in the file, and setting the variable LANGUAGE.

    For your exercise I have inserted the swedish names ;-)

    The lfind, name, complex, numbers and parse functions are for internal
    use, called by strptime.

    Uh.. oh yeah.. if you want to get in touch with me.. I am reachable
    at flognat at fukt.hk-r.se, the newest version of this file can probably
    be found somewhere close to http://www.fukt.hk-r.se/~flognat

    If you like it, send a postcard to Andy Eskilsson
                                       Kämnärsv. 3b228
				         	   S-226 46 Lund
				      	   Sweden

So, if you like, send him a postcard, but I think the code is pretty useful.

- Mark
----------------------------------------------
The opinions expressed are mine, and are not necessarily those of my
employer.




-----Original Message-----
From: David C. Ullrich [mailto:david_ullrich at my-deja.com]
Sent: Monday, August 07, 2000 9:47 AM
To: python-list at python.org
Subject: Re: time.strptime() not supported in windows? what the.....


In article <YdBj5.66324$6y5.43696402 at news2.rdc2.tx.home.com>,
  "Michael Morrison" <borlak at home.com> wrote:
>
> Now this is odd....
>
> windows:
> >>> time.strptime("08/07/2000 11:03", "%m/%d/%Y %H:%M")
> Traceback (innermost last):
>   File "<interactive input>", line 0, in ?
> AttributeError: strptime
>
> unix:
> >>> time.strptime("08/07/2000 11:03", "%m/%d/%Y %H:%M")
> (2000, 8, 7, 11, 3, 0, 0, 220, 0)
> >>> time.asctime(time.strptime("08/07/2000 11:03", "%m/%d/%Y %H:%M"))
> 'Mon Aug  7 11:03:00 2000'
>
> Okay...WHY isn't this function supported in windows?

     When I asked about this the answer appeared to be
"because it isn't". I'd already worked around _my_ problem,
so I didn't notice the posts a little later pointing out
that there are also date-parsing functions in the rfc822
module that may help.

> That's got to be
the
> craziest thing I've ever seen in python so far.  If you need, _ILL_
make the
> function for the windows platform.
>
>

--
Oh, dejanews lets you add a sig - that's useful...


Sent via Deja.com http://www.deja.com/
Before you buy.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: strptime.pyc
Type: application/octet-stream
Size: 8986 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20000807/3a31cb8d/attachment.obj>


More information about the Python-list mailing list