Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread William Witteman
On Wed, Feb 17, 2010 at 12:44:02PM -0600, David Perlman wrote: I have been really scratching my head over this, it seems like there *should* be a nice easy way to do what I want but I can't find it for the life of me. ... But a) I don't know how to stick the offset info into a datetime object, and

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread David Perlman
Yeah, I got this part. The thing that's hanging me up is that there doesn't seem to be any way to get a tzinfo instance that contains the current local time zone information. You can do time.timezone to get the seconds from UTC, but there doesn't seem to be any way to convert that into a

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Kent Johnson
On Wed, Feb 17, 2010 at 3:12 PM, David Perlman dperl...@wisc.edu wrote: Yeah, I got this part.  The thing that's hanging me up is that there doesn't seem to be any way to get a tzinfo instance that contains the current local time zone information.  You can do time.timezone to get the seconds

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Kent Johnson
On Wed, Feb 17, 2010 at 3:48 PM, David Perlman dperl...@wisc.edu wrote: Surely there is a way to simply print out the local time, date and time zone without needing to write your own class...  I can't believe this is the only way... Here's why I don't believe it.  Both the datetime and time

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread David Perlman
But this doesn't help, because then you still don't know whether it's dst or not. You then would have to jump through whatever convolutions to do that calculation. All I want to know is the *current* offset between local time and utc. I know the system has this information already; it

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread David Perlman
OK, here's a function that does precisely what I want: def tzDelta(): by whatever means necessary, return the current offset of the local time from utc. s=time.time() t,u=time.localtime(s),time.gmtime(s) osec=3600*(t[3]-u[3]) + 60*(t[4]-u[4]) + (t[5]-u[5]) return

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread William Witteman
On Wed, Feb 17, 2010 at 03:24:26PM -0600, David Perlman wrote: But this doesn't help, because then you still don't know whether it's dst or not. You then would have to jump through whatever convolutions to do that calculation. All I want to know is the *current* offset between local time and

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Kent Johnson
On Wed, Feb 17, 2010 at 4:37 PM, David Perlman dperl...@wisc.edu wrote: OK, here's a function that does precisely what I want: def tzDelta():  by whatever means necessary, return the current offset of the local time from utc.  s=time.time()  t,u=time.localtime(s),time.gmtime(s)  

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread Sander Sweers
On 17 February 2010 22:37, David Perlman dperl...@wisc.edu wrote: As far as I can tell, this should always work.  So wouldn't it be nice if there were a less convoluted way to get this?? There is pytz [1] which should provide a simpler way to manage timezone info in python. Greets Sander [1]

Re: [Tutor] datetime, time zones, and ISO time

2010-02-17 Thread David Perlman
On Feb 17, 2010, at 4:17 PM, Sander Sweers wrote: On 17 February 2010 22:37, David Perlman dperl...@wisc.edu wrote: As far as I can tell, this should always work. So wouldn't it be nice if there were a less convoluted way to get this?? There is pytz [1] which should provide a simpler way