🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4185

Re: mktime murk

#4185
From: Geoff Clare
Date: Thu, 05 Oct 1995 15:34
27 lines
1577 bytes
In <44uosd$1nl@light.twinsun.com> eggert@twinsun.com (Paul Eggert) writes:

>I am using US Pacific time, and I want the time ``one day after
>1993-10-31 00:00:00 tm_isdst=1'', so I pass the struct tm equivalent of
>1993-10-32 00:00:00 tm_isdst=1 to mktime.  The clock jumps back an hour at
>1993-10-31 02:00:00.  Should mktime return
>1993-10-31 23:00:00 tm_isdst=0 (1), or
>1993-11-01 00:00:00 tm_isdst=0 (2)?

>In this case, (2) is more ``correct'',
>in the sense that it corresponds better to what was expected.

What is expected depends on which meaning of "one day later" that you are
applying.  It can mean either "24 hours later", or "the same wall-clock
time on the next day".

If you expect outcome (2) you are applying the second meaning.  To obtain
this behaviour you should set tm_isdst to -1 before calling mktime().

By keeping tm_isdst set to 1 you are specifying that mktime() should
treat the input time as if it was DST, even though DST is not in effect
at that time.  This is consistent with the "24 hours later" meaning and
so you should expect outcome (1).

-- 
Geoff Clare <gwc@root.co.uk>
UniSoft Limited, London, England.
Technical Details
Message-ID: <DFzFA4.Io0@root.co.uk>
Path: arc1-ca.pugleaf.net!root.co.uk!squonk!gwc
References: <44mio5$63n@mark.ucdavis.edu> <812657476snz@genesis.demon.co.uk> <44qa5g$qj8@tattoo.twinsun.com> <44u7um$elm@info1.sdrc.com> <44uosd$1nl@light.twinsun.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!root.co.uk!squonk!gwc
From: gwc@root.co.uk (Geoff Clare)
Subject: Re: mktime murk
Message-ID: <DFzFA4.Io0@root.co.uk>
Date: Thu, 5 Oct 1995 15:34:52 GMT
References: <44mio5$63n@mark.ucdavis.edu> <812657476snz@genesis.demon.co.uk> <44qa5g$qj8@tattoo.twinsun.com> <44u7um$elm@info1.sdrc.com> <44uosd$1nl@light.twinsun.com>
Organization: UniSoft Ltd., London, England