nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

mktime() does not "normalize" struct tm argument

Open pkarashchenko opened this issue 3 years ago • 0 comments

Linux mktime:

The mktime() function modifies the fields of the tm structure as follows: tm_wday and tm_yday
are set to values determined from the contents of the other fields; if structure members are
outside their valid interval, they will be normalized (so that, for example, 40 October is changed
into 9 November); tm_isdst is set (regardless of its initial value) to a positive value or to 0,
respectively, to indicate whether DST is or is not in effect at the specified time. Calling mktime()
also sets the external variable tzname with information about the current timezone.

FreeBSD mktime:

     The original values of the	tm_wday	and tm_yday components of the struc-
     ture are ignored, and the original	values of the other components are not
     restricted	to their normal	ranges,	and will be normalized if needed.  For
     example, October 40 is changed into November 9, a tm_hour of -1 means 1
     hour before midnight, tm_mday of 0	means the day preceding	the current
     month, and	tm_mon of -2 means 2 months before January of tm_year.	(A
     positive or zero value for	tm_isdst causes	mktime() to presume initially
     that summer time (for example, Daylight Saving Time) is or	is not in ef-
     fect for the specified time, respectively.	 A negative value for tm_isdst
     causes the	mktime() function to attempt to	divine whether summer time is
     in	effect for the specified time.	The tm_isdst and tm_gmtoff members are
     forced to zero by timegm().)

OpenGroup mktime does not state anything about normalization.

pkarashchenko avatar Aug 11 '22 07:08 pkarashchenko