diff --git a/library/changes b/library/changes index ec03b84..a5707e6 100644 --- a/library/changes +++ b/library/changes @@ -7,7 +7,12 @@ function. - The fall-back function for converting time into a string in strftime() - now calls itself for the "%x" and "%X" format specifiers. + now calls itself for the "%c", "%x" and "%X" format specifiers. + +- mktime() is supposed to convert the time specification, given as local + time, into the number of seconds since January 1st, 1970, relative to + UTC. This didn't really work up until now since the time value returned + was given as local time. c.lib 1.186 (14.1.2005) diff --git a/library/time_localtime_r.c b/library/time_localtime_r.c index b449db7..79fc55e 100644 --- a/library/time_localtime_r.c +++ b/library/time_localtime_r.c @@ -1,5 +1,5 @@ /* - * $Id: time_localtime_r.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: time_localtime_r.c,v 1.3 2005-01-25 11:21:00 obarthel Exp $ * * :ts=4 * @@ -67,8 +67,8 @@ localtime_r(const time_t *t,struct tm * tm_ptr) } #endif /* CHECK_FOR_NULL_POINTERS */ - /* The time parameter given represents local time and - * must be converted to UTC before we proceed. + /* The time parameter given represents UTC and + * must be converted to local time before we proceed. */ if(__default_locale != NULL) gmt_offset = 60 * __default_locale->loc_GMTOffset; diff --git a/library/time_mktime.c b/library/time_mktime.c index 15baa8f..8cbb62a 100644 --- a/library/time_mktime.c +++ b/library/time_mktime.c @@ -1,5 +1,5 @@ /* - * $Id: time_mktime.c,v 1.3 2005-01-24 10:25:46 obarthel Exp $ + * $Id: time_mktime.c,v 1.4 2005-01-25 11:21:00 obarthel Exp $ * * :ts=4 * @@ -41,6 +41,10 @@ #include "time_headers.h" #endif /* _TIME_HEADERS_H */ +#ifndef _LOCALE_HEADERS_H +#include "locale_headers.h" +#endif /* _LOCALE_HEADERS_H */ + /****************************************************************************/ time_t @@ -185,6 +189,11 @@ mktime(struct tm *tm) tm->tm_yday = (seconds - delta) / (24 * 60 * 60); + /* The data in 'struct tm *tm' was given in local time. We need + to convert the result into UTC. */ + if(__default_locale != NULL) + seconds += 60 * __default_locale->loc_GMTOffset; + /* Finally, adjust for the difference between the Unix and the AmigaOS epochs, which differ by 8 years. */ result = seconds + UNIX_TIME_OFFSET; diff --git a/library/time_time.c b/library/time_time.c index 10be595..3d77466 100644 --- a/library/time_time.c +++ b/library/time_time.c @@ -1,5 +1,5 @@ /* - * $Id: time_time.c,v 1.3 2005-01-24 10:25:46 obarthel Exp $ + * $Id: time_time.c,v 1.4 2005-01-25 11:21:00 obarthel Exp $ * * :ts=4 * @@ -52,7 +52,8 @@ time(time_t * tptr) PROFILE_ON(); /* This converts the DateStamp contents into the number of - seconds elapsed since January 1st 1970. */ + seconds elapsed since January 1st 1970. The time is + given as relative to UTC, not local time. */ result = __convert_datestamp_to_time(&ds); if(tptr != NULL)