By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,896 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,896 IT Pros & Developers. It's quick & easy.

problem with "time"

P: n/a
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!
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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+R7tjr 7mXiKi2ACfdKQ+
lQr4naciiBoqD3iRQuQu5xk=
=rwRs
-----END PGP SIGNATURE-----

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.