473,738 Members | 8,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with "time"

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
1 1454
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)

iD8DBQFCLgRRJd0 1MZaTXX0RAo8YAK CTgLBPBJOZ00Wr+ R7tjr7mXiKi2ACf dKQ+
lQr4naciiBoqD3i RQuQu5xk=
=rwRs
-----END PGP SIGNATURE-----

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
10509
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am using C# eg. - String variable "strMyDate" holds the value "1/1/2005 12:00:00 AM" from the database. - I do not care about the time portion, I only want "1/1/2005" for display.
22
4913
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially when working with large projects. It is *much* better to catch errors at "compile-time" rather than at run-time. One thing I've "found" is the PyChecker module (conveniently embedded in SPE), but it doesn't seem to do that great of a job. ...
2
7976
by: Paul Brady | last post by:
I have non-computer skilled users entering data into a form. There are certain ranges of values which, if they enter them, make no sense in the application, but I can't test them until they try to close out the form, in which case I can look at the entire set of values and see if they're OK. So, I have this code. for the "Before Update" event: if (their variables are inappropriate) then msgbox "You've entered bad variables (or some...
9
6018
by: rnn98 | last post by:
hi, my multithread application, running under solaris box, is crashing eventually. I tried to spot and substitute functions not "thread safe", but I guess my search wasn't good enough. I have put localtime_r and asctime_r where I was using localtime and asctime. But I didn't find any correspondent _r function to "time".Also, I found that "readdir" is not thread safe. But what about "scandir"? Thanks for any help
4
4118
by: bingfeng | last post by:
I have some codes generated by perl, in which initialize some huge struct,such as PARA TOS_network_spantree_set_0_para_0 = { "vlan", emNUM, NULL, "", "configuration on a designated vlan", PRO_REQUIRED }; const char* TOS_network_spantree_set_0_para_1_emvalue = { "disable", "enable", NULL }; PARA TOS_network_spantree_set_0_para_1 = { "", emENUM, TOS_network_spantree_set_0_para_1_emvalue, "", "enable or disable STP", PRO_REQUIRED };
4
1275
by: Lars Netzel | last post by:
Is there any way to add some code that will happen in every single Event that i raised in a form? I have a Total field in the bottom of a pretty complex page and I think it's kind of "Dirty" to update that Filed from every single Event that might affect it Is there are was to keep that Filed Total (a value) updated at all time without having to think about it in every single event on the page?
16
10529
by: John Kelsey | last post by:
Back in the "old" days with C, I used to do something like... struct { char Description; float price; } Items = { {"Apple", 1.99}, {"Banana", 2.04}
0
2164
by: Shaun | last post by:
Hi all, I'm trying to implement a custom session handler that writes session data to a MySQL database. It works fine about 99% of the time. Trouble is, at random intervals, I get entries like the following in my php-error.log: PHP Warning: Unknown: A session is active. You cannot change the session module's ini settings at this time. in Unknown on line 0
17
3921
by: teddysnips | last post by:
One of my clients has asked me to make a change to one of their Access applications. The application is a Front End/Back End standard app. I didn't develop it, but looking at it tells me that it was done entirely using the Wizards. There is no log-in procedure. They want to amend it so that only one person can be logged in at any one time. So, if Joe Bloggs tries to open the application, and Fred Jones has already connected, Joe...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.