Zugriff auf Windows Dateieigenschaften

Steve Holden sholden at holdenweb.com
Fri Nov 2 07:53:09 EST 2001


"Andreas" <joeyahoo at gmx.de> wrote in message
news:cd02ab5d.0111012337.22e3cec3 at posting.google.com...
> Hi Martin,
>
> well I haven't used newsgroups and stuff like that so often up to now
> ... but English should be no problem ... thanks for this friendly
> advice ...
>
> ;-)
>
> Yesterday I had a look at the different modules again and found the
> time modul which will return the date but in a format like " Thu Nov
> 01 16:30:25 2001".
> Does anybody know how Python handles internally dates because one
> cannot work with the date as it appears there. I guess internally it
> should be transfered to a number refering to a special dateline like
> under UNIX.
>
Perhaps you should take a closer look :-) The time module is capable of
handling times in all sorts of formats. Specifically, the time module works
with date/time values defined as for Unix, i.e. fractional seconds since the
Unix epoch. These are the values returned by time.time().

Most other things seems to wan to work with tuples, which both gmtime() and
localtime() will produced from fractional seconds. To go back to seconds
from tuples use time.mktime(t) where t is a time tuple.

>>> import time as t
>>> t.time()
1004704959.12
>>> t.localtime(t.time())
(2001, 11, 2, 7, 42, 55, 4, 306, 0)
>>> t.ctime(t.time())
'Fri Nov 02 07:43:29 2001'
>>> t.strftime("%A %B %d %Y %I:%M %p", t.localtime(t.time()))
'Friday November 02 2001 07:47 AM'
>>> t.mktime(t.localtime(t.time())), t.time()
(1004705505.0, 1004705505.3)
>>> t.gmtime(0) # the epoch
(1970, 1, 1, 0, 0, 0, 3, 1, 0)
>>>

still-worrying-about-april-2038-ly y'rs  - steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list