problem with "time"

A

a_geek

Hello,

I'm writing a small program that needs to check Unix timestamps for
falling into an interval (typical usage: ./program 2005-03, you get
the idea). Now, I create two time stamps from the user's input to
create the interval's borders using mktime(). Trying to check the sanity
of my program, I also converted the values back to tuples using
localtime(). Unfortunately, I get back one of them with the DST flag
set, and the other with the DST flag unset.

I have _no_ idea on how localtime() could reasonably synthesize
different values for that flag for _any_ time value converted in about
the same millisecond. What gives?

Thank you!
 
J

Jeff Epler

Without your code, it's hard to tell.

Here's a small program I wrote:
import time

t = time.time()
print time.localtime(t - 86400)
print time.localtime(t)
on both lines, the tm_isdst flag is the same.

If I choose two times that are on either side of the DST change in
my timezone, I get different answers:
import time

t = time.time()
print time.localtime(t)
print time.localtime(t+86400 * 90)
Here, I get different values for tm_isdst because DST is in effect for
one of the times but not the other.
I have _no_ idea on how localtime() could reasonably synthesize
different values for that flag for _any_ time value converted in about
the same millisecond. What gives?

The tm_isdst field is not about the DSTness at the time of
conversion---it's about the DSTness of the converted time.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCLgRRJd01MZaTXX0RAo8YAKCTgLBPBJOZ00Wr+R7tjr7mXiKi2ACfdKQ+
lQr4naciiBoqD3iRQuQu5xk=
=rwRs
-----END PGP SIGNATURE-----
 

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

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,140
Members
47,755
Latest member
Grazynkaa

Latest Threads

Top