diff --git a/library/changes b/library/changes index a906500..a5f714c 100644 --- a/library/changes +++ b/library/changes @@ -54,6 +54,12 @@ %a/%A conversions for C99. The %j is treated like %ll; %t and %z are treated like %l. Also, the "inf"/"infinity"/"nan"/"nan()" keywords are processed. +- The strftime() %z conversion now prints the time zone difference as a + "decimal" number. That is, if the difference is 5 hours and 30 minutes, + then %z will now print "530" rather than "330". + +- mktime() now handles one leap second gracefully. + c.lib 1.191 (9.4.2005) diff --git a/library/time_mktime.c b/library/time_mktime.c index cda7f12..74e6e63 100644 --- a/library/time_mktime.c +++ b/library/time_mktime.c @@ -1,5 +1,5 @@ /* - * $Id: time_mktime.c,v 1.8 2005-02-27 21:58:21 obarthel Exp $ + * $Id: time_mktime.c,v 1.9 2005-05-09 13:47:24 obarthel Exp $ * * :ts=4 * @@ -155,21 +155,23 @@ mktime(struct tm *tm) goto out; } - if(tm->tm_sec < 0 || tm->tm_sec > 59) + /* Note: the number of seconds can be larger than 59 + in order to account for leap seconds. */ + if(tm->tm_sec < 0 || tm->tm_sec > 60) { SHOWVALUE(tm->tm_sec); SHOWMSG("invalid seconds"); goto out; } - clock_data.sec = tm->tm_sec; + clock_data.sec = (tm->tm_sec > 59) ? 59 : tm->tm_sec; clock_data.min = tm->tm_min; clock_data.hour = tm->tm_hour; clock_data.mday = tm->tm_mday; clock_data.month = tm->tm_mon + 1; clock_data.year = tm->tm_year + 1900; - seconds = Date2Amiga(&clock_data); + seconds = Date2Amiga(&clock_data) + (tm->tm_sec - 59); /* The AmigaOS "epoch" starts with January 1st, 1978, which was a Sunday. */ diff --git a/library/time_strftime.c b/library/time_strftime.c index d9f9919..f9fc775 100644 --- a/library/time_strftime.c +++ b/library/time_strftime.c @@ -1,5 +1,5 @@ /* - * $Id: time_strftime.c,v 1.13 2005-05-08 11:27:26 obarthel Exp $ + * $Id: time_strftime.c,v 1.14 2005-05-09 13:47:24 obarthel Exp $ * * :ts=4 * @@ -431,6 +431,10 @@ format_date(const char *format,const struct tm *tm,struct Hook * hook) __locale_unlock(); + /* The GMT offset is given in minutes. We need to print + it as a decimal number. */ + gmt_offset = (100 * (gmt_offset / 60)) + (gmt_offset % 60); + __number_to_string((unsigned int)gmt_offset,buffer,sizeof(buffer),0); store_string_via_hook(buffer,-1,hook);