|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Question about time.gmtimeHello, I had a problem with a script yesterday that made me puzzled.
My time zone is US Mountain Time. This script was running nice last week, but yesterday it reported the date of today instead So, yesterday at 5:20pm this line: hoje = time.strftime("%a, %b %d, %Y", time.gmtime()) Gave me this: "Tue, Sep 29, 2009" instead of "Mon, Sep 28, 2009" What's going on? Minutes ago, while I was investigating this I had this output: >>> time.gmtime() time.struct_time(tm_year=2009, tm_mon=9, tm_mday=29, tm_hour=14, tm_min=48, tm_sec=49, tm_wday=1, tm_yday=272, tm_isdst=0) >>> time.localtime() time.struct_time(tm_year=2009, tm_mon=9, tm_mday=29, tm_hour=8, tm_min=50, tm_sec=28, tm_wday=1, tm_yday=272, tm_isdst=1) I see there are 6 hours difference, but I'm sure the script ran before 6pm Should I simply modify my code to use localtime, instead? Why did it happen only yesterday? I'm using Windows XP Professional, and my clock says it's Tuesday, Sept. 29, 2009 and 9:10 AM Regards, Eduardo _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
|
|
Re: Question about time.gmtimeOn Tue, Sep 29, 2009 at 8:11 AM, Eduardo Vieira <eduardo.susan@...> wrote:
> Hello, I had a problem with a script yesterday that made me puzzled. > My time zone is US Mountain Time. This script was running nice last > week, but yesterday it reported the date of today instead > So, yesterday at 5:20pm this line: > hoje = time.strftime("%a, %b %d, %Y", time.gmtime()) > > Gave me this: "Tue, Sep 29, 2009" instead of "Mon, Sep 28, 2009" > What's going on? > Minutes ago, while I was investigating this I had this output: > >>>> time.gmtime() > time.struct_time(tm_year=2009, tm_mon=9, tm_mday=29, tm_hour=14, > tm_min=48, tm_sec=49, tm_wday=1, tm_yday=272, tm_isdst=0) >>>> time.localtime() > time.struct_time(tm_year=2009, tm_mon=9, tm_mday=29, tm_hour=8, > tm_min=50, tm_sec=28, tm_wday=1, tm_yday=272, tm_isdst=1) > > I see there are 6 hours difference, but I'm sure the script ran before 6pm > Should I simply modify my code to use localtime, instead? Why did it > happen only yesterday? > > I'm using Windows XP Professional, and my clock says it's Tuesday, > Sept. 29, 2009 and 9:10 AM > > Regards, > > Eduardo > Some time ago I experienced that. And today again. I wonder if it's not related to the fact that I did some system restore operations today? _______________________________________________ Tutor maillist - Tutor@... To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor |
| Free embeddable forum powered by Nabble | Forum Help |