On Tue, Jan 21, 2014 at 09:34:51AM +0100, Otto Moerbeek wrote: > On Tue, Jan 21, 2014 at 09:08:18PM +1300, Philip Guenther wrote: > > > On Tue, Jan 21, 2014 at 8:33 PM, Otto Moerbeek <o...@drijf.net> wrote: > > ... > > > Right. what happens is that localtime(3) returns NULL, because the > > > year is not representable as an int. struct tm.tm_year must be an int > > > according to posix. > > > > > > The diff below catches the case. > > > > ok guenther@ > > > > > > > But it does not solve that 64-bit > > > time_t can represent years that do not fit into the int sized tm_year. > > > > Sure, and before there was the problem that there were struct > > localtime values that mktime() could not convert to a time_t. Lacking > > types of fractional bit width, we have to live with one or the other, > > no? > > indeed, it's one or the other. > > I need to check which of the time functions can returns NULL. The man > page is awfully silent on that. > > -Otto > > > > > > > Philip Guenther
And here's the man page diff, our ctime and asctime actually do not ever return NULL, while posix allows that. -Otto Index: ctime.3 =================================================================== RCS file: /cvs/src/lib/libc/time/ctime.3,v retrieving revision 1.40 diff -u -p -r1.40 ctime.3 --- ctime.3 17 Jul 2013 05:42:11 -0000 1.40 +++ ctime.3 21 Jan 2014 09:43:31 -0000 @@ -257,6 +257,17 @@ is non-zero if summer time is in effect. is the offset (in seconds) of the time represented from UTC, with positive values indicating east of the Prime Meridian. +.Sh RETURN VALUES +The functions +.Fn localtime , +.Fn localtime_r , +.Fn gmtime +and +.Fn gmtime_r +return NULL on error. +The function +.Fn mktime +returns \-1 on error. .Sh FILES .Bl -tag -width "/usr/share/zoneinfo/posixrules" -compact .It Pa /usr/share/zoneinfo