1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

mktime() returns a time_t. time_t is often 32 bits, even on many architectures

that feature 64 bit 'long'.

Some systems have 64 bit time_t and deal with years beyond 2038. However, even
some of the systems with 64 bit time_t returns -1 for dates beyond 03:14:07
UTC, January 19, 2038. (Such as AIX 5100-06)
This commit is contained in:
Daniel Stenberg 2005-03-08 16:31:56 +00:00
parent 5cd9f57137
commit 8a96aec567
2 changed files with 14 additions and 2 deletions

View File

@ -85,7 +85,12 @@ This function returns -1 when it fails to parse the date string. Otherwise it
returns the number of seconds as described. returns the number of seconds as described.
If the year is larger than 2037 on systems with 32 bit time_t, this function If the year is larger than 2037 on systems with 32 bit time_t, this function
will return 0x7fffffff (since that is the largest possible 31 bit number). will return 0x7fffffff (since that is the largest possible signed 32 bit
number).
Having a 64 bit time_t is not a guarantee that dates beyond 03:14:07 UTC,
January 19, 2038 will work fine. On systems with a 64 bit time_t but with a
crippled mktime(), \fIcurl_getdate\fP will return -1 in this case.
.SH REWRITE .SH REWRITE
The former version of this function was built with yacc and was not only very The former version of this function was built with yacc and was not only very
large, it was also never quite understood and it wasn't possible to build with large, it was also never quite understood and it wasn't possible to build with

View File

@ -369,10 +369,17 @@ static time_t Curl_parsedate(const char *date)
tm.tm_yday = 0; tm.tm_yday = 0;
tm.tm_isdst = 0; tm.tm_isdst = 0;
/* mktime() returns a time_t. time_t is often 32 bits, even on many
architectures that feature 64 bit 'long'.
Some systems have 64 bit time_t and deal with years beyond 2038. However,
even some of the systems with 64 bit time_t returns -1 for dates beyond
03:14:07 UTC, January 19, 2038. (Such as AIX 5100-06)
*/
t = mktime(&tm); t = mktime(&tm);
/* time zone adjust */ /* time zone adjust */
{ if(-1 != t) {
struct tm *gmt; struct tm *gmt;
long delta; long delta;
time_t t2; time_t t2;