473,698 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getmtim e() used to return an integer representing
the local time.

in Python 2.5 os.path.getmtim e() 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.p ath.getmtime('f oo.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 3081
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.getmtim e() 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.getmtim e() 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.p ath.getmtime('f oo.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>\python 24\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.s tat(fn).s
t_mtime), time.ctime(os.p ath.getmtime(fn ))
Fri May 04 07:40:03 2007 Fri May 04 07:40:03 2007
>>^Z

C:\junk>\python 25\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.s tat(fn).s
t_mtime), time.ctime(os.p ath.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_t imes.

May 3 '07 #2

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

Similar topics

3
1578
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 here's the catch. Changes are computed using (1) log file from the last deployment and (2) local file system. Log file contains datestamps (integers) returned from os.path.getmtime(f) function at the time of last deployment. So i'm comparing two...
5
3317
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 3600 seconds ie. one hour, even if the file remains the same. I've tried using win32file.GetFileTime, and it reports a consistent number, regardless of DST.
5
4037
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 think - it might have been XP) to 2003. The database is impressive, both in what it does and the obtuse and inconsistent ways it works. There are several hundred queries, for example, with no indication of where they are used or if they are in fact...
19
3871
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 ReuseParameterValuesOnRefresh="True" in a viewer, but it still doesn't work. Did anyone run into this problem. What's the solution? Please help. Thank you
16
2053
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 on Python 2.4 and Python 2.5 by the timezone.
3
19535
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 compile. threshold_time = datetime.date.today() - datetime.timedelta(days=30) mod_time = os.path.getmtime(file_path)
0
8671
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9016
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8856
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4360
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4613
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2321
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.