Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > mktime and DST.

Reply
Thread Tools

mktime and DST.

 
 
Gore
Guest
Posts: n/a
 
      10-07-2003
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
 
Reply With Quote
 
 
 
 
Richard Bos
Guest
Posts: n/a
 
      10-07-2003
http://www.velocityreviews.com/forums/(E-Mail Removed) (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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
localtime and mktime mhearne808[insert-at-sign-here]gmail[insert-dot-here]com Perl Misc 2 07-01-2007 02:54 PM
time.mktime problem McBooCzech Python 4 09-05-2005 09:35 AM
mktime segfault Florian Quetting C++ 2 12-31-2004 05:45 PM
time.mktime memory access violation bug Bengt Richter Python 6 11-21-2003 03:07 AM
GMT equivalent of mktime Rajmohan C Programming 1 07-14-2003 09:27 PM



Advertisments