473,795 Members | 3,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mktime and DST.

hi,

I tried the following piece of code
long sec = -1;
struct tm date;
date.tm_year = 1995 - 1900;
date.tm_mon = 7 - 1;
date.tm_mday = 16;
date.tm_hour = 0;
date.tm_min = 0;
date.tm_sec = 0;

date.tm_isdst = 0;

sec = mktime(&date);

The value returned by mktime when tm_isdst is set to 0 is different
from the value returned by mktime when tm_isdst is set to -1 or 1. Why
is that?
The date given is 16th July 1995 00:00:00.

The compiler is used MSVC 6.0 Service pack 5.
Observed the same behavious on Sun Solaris.
My machine has the us-pacific time set ( GMT - 8 Hours ).

Mihir
Nov 13 '05 #1
1 5906
mi*******@hotma il.com (Gore) wrote:
I tried the following piece of code
long sec = -1;
struct tm date;
date.tm_year = 1995 - 1900;
date.tm_mon = 7 - 1;
date.tm_mday = 16;
date.tm_hour = 0;
date.tm_min = 0;
date.tm_sec = 0;

date.tm_isdst = 0;

sec = mktime(&date);

The value returned by mktime when tm_isdst is set to 0 is different
from the value returned by mktime when tm_isdst is set to -1 or 1. Why
is that?
The date given is 16th July 1995 00:00:00.


Because your system thinks that DST is in place at that date and time in
your time zone. It certainly is in my timezone at that date.
tm_isdtd==0 means "I know DST is not in effect. Compute this timestamp
assuming that it isn't." tm_isdst>0 means "I know DST is in effect.
Compute this timestamp assuming that it is." tm_isdst<0 means "I don't
know whether DST is in effect now. Please determine this for me, then
compute this timestamp with the determined DST setting."
If the computer thinks DST is in effect, then yes, tm_isdst==-1 would
give the same result as tm_isdst==1. Had it thought DST were not in
effect, tm_isdst==-1 would give the same result as tm_isdtd==0.

Richard
Nov 13 '05 #2

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

Similar topics

1
2748
by: adam | last post by:
Hi all, I am having a problem with calculating a date. What I am looking to do is get the date of Sunday of this week, then use mktime() to find out other days in the past by subtracting days. In the code below, today is Saturday, October 16, 2004, this week's Sunday is 2004-10-17. I successfully get that. But, when I try to subtract 7 days using mktime(), I instead of getting
9
2186
by: WebM¤nkey | last post by:
Hi folks Just found that the mktime function returns a negative value when the date is 26 march 2006 with 0 hours, 0 seconds and 0 minutes. Is this a documented problem ? Any suggestions ?
2
2508
by: Bengt Richter | last post by:
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> time.mktime((1969, 12, 31, 17, 0, 0, 0, 0, 0)) 3600.0 >>> time.mktime((1969, 12, 31, 17, 0, 0, 0, 0, 1)) 0.0 >>> time.mktime((1969, 12, 31, 16, 0, 0, 0, 0, 1))
2
4714
by: Florian Quetting | last post by:
Hi, I'm getting mad with following problem: The code compiles, but I always get a segfault and I don't have any clue why. I can't see any differences in my way of calling mktime and others. --------------------------------------------------------------------------- #include <iostream> #include <sys/stat.h>
4
10249
by: McBooCzech | last post by:
Hi, on Linux (Fedora FC4) and Python 2.4.1 I am trying to know the time delta in seconds between two times given in the HHMMSS format. My code looks like: import datetime, time ta1=(time.strptime('000001', '%H%M%S')) ta2=(time.strptime('230344', '%H%M%S')) t1=time.mktime(ta1) t2=time.mktime(ta2) print t1, t2
1
24531
by: KW | last post by:
Hi all, Appreciate if someone can help me out on this. Currently, I have a tm structure holding information of the UTC time, which is very likely to be in the past, meaning not the current time. So, let's say I'm in CST(-6) now, and I want to know the equivalent local time of that tm structure, how do I do that taking into consideration daylight savings adjustments?
16
14350
by: John Hanley | last post by:
I created a function that breaks down a date into broken down time, I subtract a certain number of seconds from that, then use mktime() to recompute the calendar time. It works basically except every so often, I get the date 060207 (Feb 7, 2006) which is obviously not correct. When it does this it always gives me this date. I tracked it down to my mktime() call, when I get to a certain date, mktime returns a number in 4000000000,...
2
3961
by: John Hanley | last post by:
I am getting some inconsistencies with mktime(). I allocate memory for my struct tm early in my program, and assign only *some* of the member variables. t->tm_sec=s; t->tm_min=m; t->tm_hour=h; t->tm_mday=d;
2
2771
by: pedalpete | last post by:
I've got this error which keeps popping up, but I can't seem to figure out why. The error reads ' A non well formed numeric value encountered in filename on line <b>198</b>'. the lines which contain the error are all the same. list($sHour, $sMin, $sSec)=split(':', $startTime2);
5
2191
by: Robert Latest | last post by:
Here's what happens on my Windows machine (Win XP / Cygwin) at work. I've googled a bit about this problem but only found references to instances where people referred to dates before the Epoch. Of course at home on my Linux box everything works. I know that everything has its limits somewhere, but I've never heard of March 2008 being a problem. Tomorrow I'm going to write a test loop that shows me the exact last
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10165
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
10001
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
9043
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
6783
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
5437
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...
1
4113
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
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.