lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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