Summary: | mktime() fails under certain conditions | ||
---|---|---|---|
Product: | Base System | Reporter: | Andre Albsmeier <Andre.Albsmeier> |
Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | ||
Priority: | Normal | ||
Version: | Unspecified | ||
Hardware: | Any | ||
OS: | Any |
Description
Andre Albsmeier
1999-12-16 20:20:01 UTC
In message <199912162016.VAA97593@internal>, Andre Albsmeier writes: >mktime() fails if it is called with a time that is exactly >the moment when daylight saving time is starting. Well, at least for the "spring forward case" that time doesn't exist: 01:59:57 01:59:58 01:59:59 03:00:00 There is no 02:00:00 that night. If they test for that, they're crazy. -- Poul-Henning Kamp FreeBSD coreteam member phk@FreeBSD.ORG "Real hackers run -current on their laptop." FreeBSD -- It will take a long time before progress goes too far! On Thu, 16-Dec-1999 at 21:24:41 +0100, Poul-Henning Kamp wrote:
> In message <199912162016.VAA97593@internal>, Andre Albsmeier writes:
>
> >mktime() fails if it is called with a time that is exactly
> >the moment when daylight saving time is starting.
>
> Well, at least for the "spring forward case" that time doesn't
> exist:
>
> 01:59:57
> 01:59:58
> 01:59:59
> 03:00:00
>
> There is no 02:00:00 that night. If they test for that, they're
> crazy.
Yes, the time does not exist. However, I only wonder it our
behaviour of returning an error is correct in this case. I don't
trust the GNU/Linux guys as much as I trust FreeBSD :-) but there
might be a reason they are testing it.
I was already asked in private email if the mktime() should
succeed according to POSIX.1... Does somebody know anything
about that?
-Andre
<<On Thu, 16 Dec 1999 21:16:20 +0100 (CET), Andre Albsmeier <andre.albsmeier@mchp.siemens.de> said: > mktime() fails if it is called with a time that is exactly > the moment when daylight saving time is starting. > The configure program of certain gnu software tests mktime() > for the failure described above. This fails on FreeBSD and > so configure assumes there is no working mktime available. ``certain gnu software'' is broken. Bring it up with the maintainers. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick In message <19991216213647.A34480@internal>, Andre Albsmeier writes: >On Thu, 16-Dec-1999 at 21:24:41 +0100, Poul-Henning Kamp wrote: >> In message <199912162016.VAA97593@internal>, Andre Albsmeier writes: >> >> There is no 02:00:00 that night. If they test for that, they're >> crazy. > >Yes, the time does not exist. However, I only wonder it our >behaviour of returning an error is correct in this case. I don't >trust the GNU/Linux guys as much as I trust FreeBSD :-) but there >might be a reason they are testing it. > >I was already asked in private email if the mktime() should >succeed according to POSIX.1... Does somebody know anything >about that? Well, Hum. It seems to say that the fields are not constrained to their normal domains: The original values of the tm_wday and tm_yday components of the structure are ignored, and the original values of the other components are not restricted to the ranges described in the <time.h> entry. It does not describe what should happen if I ask it to make a time out of 25:100:100, but I guess most of us can agree what it should do. The trouble with passing it 02:00:00 or for that matter 02:59:00 on the "spring forward" night, is that the time doesn't exist in the first place: Ie, does 02:10:00 represent 01:59:59 + 10:59 = 03:10:00 or 03:00:00 - 50:00 = 01:10:00 Since no sane argument either way really holds water, I think returning an error is correct. -- Poul-Henning Kamp FreeBSD coreteam member phk@FreeBSD.ORG "Real hackers run -current on their laptop." FreeBSD -- It will take a long time before progress goes too far! On Thu, 16-Dec-1999 at 21:52:17 +0100, Poul-Henning Kamp wrote:
> In message <19991216213647.A34480@internal>, Andre Albsmeier writes:
> >On Thu, 16-Dec-1999 at 21:24:41 +0100, Poul-Henning Kamp wrote:
> >> In message <199912162016.VAA97593@internal>, Andre Albsmeier writes:
> >>
> >> There is no 02:00:00 that night. If they test for that, they're
> >> crazy.
> >
> >Yes, the time does not exist. However, I only wonder it our
> >behaviour of returning an error is correct in this case. I don't
> >trust the GNU/Linux guys as much as I trust FreeBSD :-) but there
> >might be a reason they are testing it.
> >
> >I was already asked in private email if the mktime() should
> >succeed according to POSIX.1... Does somebody know anything
> >about that?
>
> Well, Hum. It seems to say that the fields are not constrained
> to their normal domains:
>
> The original values of the tm_wday and tm_yday components
> of the structure are ignored, and the original values of
> the other components are not restricted to the ranges
> described in the <time.h> entry.
>
> It does not describe what should happen if I ask it to make a time
> out of 25:100:100, but I guess most of us can agree what it should
> do.
>
> The trouble with passing it 02:00:00 or for that matter 02:59:00
> on the "spring forward" night, is that the time doesn't exist in
> the first place: Ie, does 02:10:00 represent
>
> 01:59:59 + 10:59 = 03:10:00
> or
> 03:00:00 - 50:00 = 01:10:00
>
> Since no sane argument either way really holds water, I think
> returning an error is correct.
I just tried to find out how HP-UX 10.20 and IRIX 5.3 interpret this;
they both behave in the same way:
When setting tm_hour to 2 (the illegal value) the result is 891766800.
When using 1 for tm_hour we also get 891766800.
When using 0 for tm_hour we get 891763200, this is -3600 from above.
When using 3 for tm_hour the result is 891770400, this is +3600 compared
to the first two.
These two interpret the setting of tm_hour to 2 as 1. (That doesn't
imply that I think this is correct).
-Andre
On Thu, 16-Dec-1999 at 21:52:17 +0100, Poul-Henning Kamp wrote:
> In message <19991216213647.A34480@internal>, Andre Albsmeier writes:
> >On Thu, 16-Dec-1999 at 21:24:41 +0100, Poul-Henning Kamp wrote:
> >> In message <199912162016.VAA97593@internal>, Andre Albsmeier writes:
> >>
> >> There is no 02:00:00 that night. If they test for that, they're
> >> crazy.
> >
> >Yes, the time does not exist. However, I only wonder it our
> >behaviour of returning an error is correct in this case. I don't
> >trust the GNU/Linux guys as much as I trust FreeBSD :-) but there
> >might be a reason they are testing it.
> >
> >I was already asked in private email if the mktime() should
> >succeed according to POSIX.1... Does somebody know anything
> >about that?
>
> Well, Hum. It seems to say that the fields are not constrained
> to their normal domains:
>
> The original values of the tm_wday and tm_yday components
> of the structure are ignored, and the original values of
> the other components are not restricted to the ranges
> described in the <time.h> entry.
>
> It does not describe what should happen if I ask it to make a time
> out of 25:100:100, but I guess most of us can agree what it should
> do.
>
> The trouble with passing it 02:00:00 or for that matter 02:59:00
> on the "spring forward" night, is that the time doesn't exist in
> the first place: Ie, does 02:10:00 represent
>
> 01:59:59 + 10:59 = 03:10:00
> or
> 03:00:00 - 50:00 = 01:10:00
>
> Since no sane argument either way really holds water, I think
> returning an error is correct.
As I wrote initally, the problem arises when configure tries to
determine if mktime() works. I have now looked what happens in this
case: The program replaces mktime with its own call. For the record,
here is the interesting part (mktime.c, around line 277):
if (t == t1 && t != t2
&& (isdst < 0 || tm.tm_isdst < 0
|| (isdst != 0) != (tm.tm_isdst != 0)))
/* We can't possibly find a match, as we are oscillating
between two values. The requested time probably falls
within a spring-forward gap of size DT. Follow the common
practice in this case, which is to return a time that is DT
away from the requested time, preferring a time whose
tm_isdst differs from the requested value. In practice,
this is more useful than returning -1. */
break;
else if (--remaining_probes == 0)
return -1;
-Andre
State Changed From-To: open->closed I (and many others) believe that it is more correct to return an error from mktime() when it's asked to construct a time from some time that can't happen. Others belive that mktime() should succeed during leap-periods. POSIX (I'm told) doesn't specify either. IMHO this is therefore a non-issue. FreeBSD's mktime() returns an error and will stay that way. |