🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4198

Re: mktime murk

#4198
From: Paul Eggert
Date: Sat, 07 Oct 1995 20:45
37 lines
2340 bytes
scjones@thor.sdrc.com (Larry Jones) writes:

>eggert@twinsun.com (Paul Eggert) writes:
>> All the standard says (in a footnote) is that mktime must
>> ``presume initially that Daylight Savings Time ... is ... in effect
>> for the specified time''.  The standard does not say what mktime does
>> if this presumption is impossible to satisfy.

> What does it mean to say that a presumption is impossible to satisfy? 

By that phrase, I meant that the presumed initial time, isdst flag and all,
never existed (or never will exist, as the case may be).

> mktime is to presume that DST is in effect for the specified time.  If,
> after normalizing the values, it discovers that DST is not in effect at
> that time (i.e., the presumption was false), then it must further
> adjust the time

So far we're in agreement -- though the standard is murky even here.
I'm writing from memory here, since my copy of the standard is at work,
but I recall that the standard says only that out-of-range time values
should be accepted; it doesn't say what should be done with them.

Further, the standard says that local time and DST are
implementation-defined, which gives the implementation wide latitude
about what to do here.  I agree that the only reasonable interpretation
for ``Feb 0'' is ``Jan 31'', but when there are multiple reasonable
interpretations, I don't see where the standard requires one or the other.

> by the appropriate DST offset and clear the flag.

I still don't see where the standard requires this.
There is another plausible way to adjust the time, i.e. simply clear the flag.
This is better for many common cases (e.g. the ``add 1 day'' example),
and it avoids genuine ambiguity in some uncommon but real examples
(not just Newfoundland in 1988-1989, but also Uruguay between 1970 and 1974,
the Dominican Republic between 1967 and 1969, and so forth).
Technical Details
Message-ID: <456oti$s0@light.twinsun.com>
Path: arc1-ca.pugleaf.net!delphi.cs.ucla.edu!twinsun!not-for-mail
References: <44mio5$63n@mark.ucdavis.edu> <812657476snz@genesis.demon.co.uk> <452i5b$8s4@light.twinsun.com> <4567mh$3fb@info1.sdrc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!delphi.cs.ucla.edu!twinsun!not-for-mail
From: eggert@twinsun.com (Paul Eggert)
Newsgroups: comp.std.c
Subject: Re: mktime murk
Date: 7 Oct 1995 13:45:38 -0700
Organization: Twin Sun Inc, El Segundo, CA, USA
Message-ID: <456oti$s0@light.twinsun.com>
References: <44mio5$63n@mark.ucdavis.edu> <812657476snz@genesis.demon.co.uk> <452i5b$8s4@light.twinsun.com> <4567mh$3fb@info1.sdrc.com>
NNTP-Posting-Host: light.twinsun.com