getmtime in 2.5 reports GMT instead of local time

J

Josef Dalcolmo

Hello,

I have tried this only on Windows XP.

in Python 2.4 os.path.getmtime() used to return an integer representing
the local time.

in Python 2.5 os.path.getmtime() reports a float representing the GMT of the
file's modification time.

Since I could not find any documentation to this behavioural change, I am asking
here: was this change intentional? Is it going to stay? Windows reports
the same time for the file as Python 2.4 used to. So I am tempted to
call this a bug, but wanted some feedback from the developers,
before filing a bug report.


If you want to test this, make sure your local time differs from GMT,
then do:

import os, time
print time.ctime(os.path.getmtime('foo.txt'))

on a file foo.txt, once with Python 2.4 then with Python 2.5,
and you should see what I mean.

- Josef
 
J

John Machin

Hello,

I have tried this only on Windows XP.

in Python 2.4 os.path.getmtime() used to return an integer representing
the local time.

The docs say "seconds since the epoch". Noting that the epoch is
usually defined with reference to UTC, "local time" is rather
unlikely.
in Python 2.5 os.path.getmtime() reports a float representing the GMT of the
file's modification time.

Since I could not find any documentation to this behavioural change, I am asking
here: was this change intentional? Is it going to stay? Windows reports
the same time for the file as Python 2.4 used to. So I am tempted to
call this a bug, but wanted some feedback from the developers,
before filing a bug report.

If you want to test this, make sure your local time differs from GMT,
then do:

import os, time
print time.ctime(os.path.getmtime('foo.txt'))

on a file foo.txt, once with Python 2.4 then with Python 2.5,
and you should see what I mean.

No way, Jose.

C:\junk>\python24\python
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information...path.getmtime(fn)
1178228403 1178228403t_mtime), time.ctime(os.path.getmtime(fn))
Fri May 04 07:40:03 2007 Fri May 04 07:40:03 2007

C:\junk>\python25\python
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information...path.getmtime(fn)
1178228403.3 1178228403.3t_mtime), time.ctime(os.path.getmtime(fn))
Fri May 04 07:40:03 2007 Fri May 04 07:40:03 2007
My TZ is 10 hours (plus/minus daylight saving) away from UTC. The
above ctime results are correct AFAICT to plus/minus a few minutes.
The change from integer to float in 2.5 is documented under
os.stat_float_times.
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top