473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

getmtime in 2.5 reports GMT instead of local time

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
May 3 '07 #1
1 3066
On May 4, 12:26 am, Josef Dalcolmo <Josef.Dalco...@gmx.netwrote:
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.
>>import os, os.path, time; fn = 'hello_u.txt'; print os.stat(fn).st_mtime, os
..path.getmtime(fn)
1178228403 1178228403
>>import os, os.path, time; fn = 'hello_u.txt'; print time.ctime(os.stat(fn).s
t_mtime), time.ctime(os.path.getmtime(fn))
Fri May 04 07:40:03 2007 Fri May 04 07:40:03 2007
>>^Z

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.
>>import os, os.path, time; fn = 'hello_u.txt'; print os.stat(fn).st_mtime, os
..path.getmtime(fn)
1178228403.3 1178228403.3
>>import os, os.path, time; fn = 'hello_u.txt'; print time.ctime(os.stat(fn).s
t_mtime), time.ctime(os.path.getmtime(fn))
Fri May 04 07:40:03 2007 Fri May 04 07:40:03 2007
>>^Z
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.

May 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Qvx | last post by:
Hello, I'we written a simple web deployment program which scans for the changes made to local copy of web site. Changed files are than packaged into a zip file and deployed to web server. Now...
5
by: Jorg Rødsjø | last post by:
Hi I'm trying to use os.path.getmtime to check if a file has been modified. My OS is WinXP. The problem is, that when the os changes from/to daylight savings time, the result is suddenly off by...
5
by: Jerry Hull | last post by:
I'm working with a database developed by an untrained person over several years - and on a network that has recently been upgraded with a new server installed and MS office upgraded from 2K (I...
19
by: LP | last post by:
I am using (trying to) CR version XI, cascading parameters feature works it asks user to enter params. But if page is resubmitted. It prompts for params again. I did set...
16
by: Josef Dalcolmo | last post by:
I tried this on Windows only: In Python 2.4 os.path.getmtime returned the local time, in Python 2.5 it seems to return GMT: import os, time print ctime.time(os.path.getmtime(foo)) differs...
3
by: junchi.tang | last post by:
Hi, I am new to python and are tryint to write a simple program delete log files that are older than 30 days. So I used os.path.getmtime(filepath) and compare it with a date but it does not...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.