Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: time module question - time zones

Reply
Thread Tools

Re: time module question - time zones

 
 
Eric Wertman
Guest
Posts: n/a
 
      05-21-2008
Sorry, my time zone is +4, not minus 4, which means that something
else is causing my source data to be in the future. I still do need
to understand where the time routines determine the time zone offset,
so I can be sure I'm passing around the neutral value.

Thanks!


On Wed, May 21, 2008 at 12:23 PM, Eric Wertman <(E-Mail Removed)> wrote:
> I tend to deal with dates a lot in different formats and places...
> typically I'll convert them to a time tuple with strptime(), and pass
> them around like that before I need to write them back out.
>
> One set of time/dates I'm getting are in UTC, but the string doesn't
> say that specifically. So I do this.. I had expected the outcome to
> be offset properly (I'm EST5EDT). But I'm obviously missing
> something:
>
> #!/usr/bin/env python
>
> import time
>
> utc_str = '2008-05-10 03:05:00 UTC'
>
> d = time.strptime(utc_str,'%Y-%m-%d %H:%M:%S %Z')
> t = time.mktime(d)
>
> print d
> print time.gmtime(t)
> print time.localtime(t)
>
> output :
>
> (2008, 5, 10, 3, 5, 0, 5, 131, 0)
> (2008, 5, 10, 8, 5, 0, 5, 131, 0)
> (2008, 5, 10, 4, 5, 0, 5, 131, 1)
>
>
> I believe that I should be getting (2008, 5, 9, 23, 5, 0, 5, 130, 1)
> out of one of those, since the original 3:05am time was UTC, and my TZ
> is currently -4. Does that make sense? I didn't even think I needed
> to do any business with time.localtime() and time.gmtime(). I
> expected time.strftime() to return the locale appropriate time, but
> it didn't.
>
> TIA
>
> Eric
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dates, time zones,daylight saving time Harlan Messinger ASP .Net 1 04-15-2010 11:27 PM
time module question - time zones Eric Wertman Python 0 05-21-2008 04:23 PM
Time Zones? Craig ASP .Net 5 01-19-2006 10:13 AM
OutputCache Duration across time zones? CJ ASP .Net 2 01-06-2006 04:59 PM
cookie expire time and time zones David Graham Javascript 6 11-22-2003 03:12 PM



Advertisments