From: Michael G Schwern Date: Mon, 15 Sep 2008 01:29:27 +0000 (-0700) Subject: Pull in changes from y2038 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c07fe26c2bb3c792760a8f9c8924bb13de4a0ad5;p=p5sagit%2Fp5-mst-13.2.git Pull in changes from y2038 Fix localtime() for negative dates. --- diff --git a/localtime64.c b/localtime64.c index ef8c40a..cfad70d 100644 --- a/localtime64.c +++ b/localtime64.c @@ -194,8 +194,6 @@ int _cycle_offset(Int64 year) Int64 exceptions = year_diff / 100; exceptions -= year_diff / 400; - assert( year >= 2001 ); - /* printf("year: %d, exceptions: %d\n", year, exceptions); */ return exceptions * 16; @@ -359,8 +357,12 @@ struct tm *localtime64_r (const Time64_T *time, struct tm *local_tm) orig_year = gm_tm.tm_year; - if (gm_tm.tm_year > (2037 - 1900)) + if (gm_tm.tm_year > (2037 - 1900) || + gm_tm.tm_year < (1902 - 1900) + ) + { gm_tm.tm_year = _safe_year(gm_tm.tm_year + 1900) - 1900; + } safe_time = TIMEGM(&gm_tm); if( localtime_r(&safe_time, local_tm) == NULL )