[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: os.time() and the last second of 1969
- From: Sean Conner <sean@...>
- Date: Sat, 12 Feb 2022 16:24:40 -0500
It was thus said that the Great Marc Balmer once stated:
>
> > Am 12.02.2022 um 14:04 schrieb Marc Balmer <marc@msys.ch>:
> >
> > (Clearing errno before mktime() is important, since it may still contain
> > a non-zero value from a previous error).
>
> At least on macOS, mktime() seems not to set set errno on illegal input
> values. This looks like highly implementation specific and maybe nothing
> should be done about it :(
The C standard says this about errno:
The value of errno is zero at program startup, but is never set to
zero by any library function.) The value of errno may be set to
nonzero by a library function call whether or not there is an error,
provided the use of errno is not documented in the description of
the function in this International Standard.
And the description of mktime() does not mention errno. Furthermore, it
says this about tm_wday and tm_yday:
On successful completion, the values of the tm_wday and tm_yday
components of the structure are set appropriately, and the other
components are set to represent the specified calendar time, but
with their values forced to the ranges indicated above; the final
value of tm_mday is not set until tm_mon and tm_year are determined.
It states nothing about not setting them in case of error, so I wouldn't
rely upon that behavior (as mentioned elsewhere in this thread).
-spc