Time problem (again)

  • Thread starter Fabio Durieux Lopes
  • Start date
F

Fabio Durieux Lopes

Hi,

I'm recreating a date-time based on a string and I have a problem
when daylight savings time is set (I'm off by 1). So today I forced
my computer into daylight savings time and debugged it again, but
this time I noticed something strange.

This is the documentation from python library reference section
6.10:

6.10 time -- Time access and conversions
....
daylight
Nonzero if a DST timezone is defined.
....


And this is what I debugged:
-> fileTimeInSecs = time.mktime(time.strptime(timeString,
"%Y%m%d%H%M"))
(Pdb) p timeString
'200803271643'
(Pdb) n
/home/salsa/Projects/TimBR_CDR/fileSync/
fileSynchronizer.py(50)passFilesOlderThan()
-> print time.daylight
(Pdb)
0

See how 'print time.daylight' resulted in '0'? Shouldn't it be Non-
zero? Do I have to set something for it to use DST?


Also, is this the right list to send questions?
 
J

Jason Scheirer

Hi,

I'm recreating a date-time based on a string and I have a problem
when daylight savings time is set (I'm off by 1). So today I forced
my computer into daylight savings time and debugged it again, but
this time I noticed something strange.

This is the documentation from python library reference section
6.10:

6.10 time -- Time access and conversions
...
daylight
Nonzero if a DST timezone is defined.
...

And this is what I debugged:
-> fileTimeInSecs = time.mktime(time.strptime(timeString,
"%Y%m%d%H%M"))
(Pdb) p timeString
'200803271643'
(Pdb) n> /home/salsa/Projects/TimBR_CDR/fileSync/

fileSynchronizer.py(50)passFilesOlderThan()
-> print time.daylight
(Pdb)
0

See how 'print time.daylight' resulted in '0'? Shouldn't it be Non-
zero? Do I have to set something for it to use DST?

Also, is this the right list to send questions?

The Python datetime module's handling of time zones is completely,
entirely deficient -- the tzinfo class is just a skeleton and
therefore useless. Install something that will give you fully
implemented time zones like at http://pytz.sourceforge.net/ and try
again -- pulling a tzinfo from this module and doing
datetime_instance.replace(tzinfo=tzinfo_object_for_timezone) on your
datetime instance parsed from the string will result in far more
predictable behavior and probably get everything behaving as you
expect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top