Re: tz strftime %V week numbers are incompatible with Solaris, GNU
The current strftime code is supposed to deliver up ISO 8601 week numbers when "%V" is used; it also delivers up ISO 8601 year numbers--either two or four digits worth--with "%g" and "%G". (The ISO 8601 year may be different from the calendar year). So far as I know, the code's current behavior matches what ISO 8601 calls for. XPG4 (as of 1994-04-09) explicitly (and presumably erroneously) called for delivering "53" as the week number in some circumstances; defining "XPG4_1994_04_09" buys this behavior. I'm eager to continue delivering ISO-8601-style numbers as the default behavior. --ado
Date: Wed, 17 Jul 96 14:18:59 EDT From: ado@elsie.nci.nih.gov (Arthur David Olson) The current strftime code is supposed to deliver up ISO 8601 week numbers when "%V" is used I assume that this is for a new or draft standard, but I'm not familiar with the standard. Is a copy available online? XPG4 (as of 1994-04-09) explicitly (and presumably erroneously) called for delivering "53" as the week number in some circumstances; defining "XPG4_1994_04_09" buys this behavior. OK, then I think I see the problem. Solaris 2.5.1 and the GNU C library both use XPG4_1994_04_09 behavior; but tz's strftime.c does not emulate this behavior correctly. (I'm guessing a bit, because I do not have the XPG4 spec.) The following patch fixes tz with XPG4_1994_04_09 so that it emulates the Solaris / GNU behavior precisely; I've tested it on all dates from 1901-12-14 through 2038-01-18. =================================================================== RCS file: RCS/strftime.c,v retrieving revision 1996.2 retrieving revision 1996.2.1.1 diff -c -r1996.2 -r1996.2.1.1 *** strftime.c 1996/01/11 01:42:39 1996.2 --- strftime.c 1996/07/17 19:23:57 1996.2.1.1 *************** *** 381,387 **** DAYSPERNYEAR; } #ifdef XPG4_1994_04_09 ! if (w == 52 && t->tm_mon == TM_JANUARY) w = 53; #endif /* defined XPG4_1994_04_09 */ if (*format == 'V') --- 381,390 ---- DAYSPERNYEAR; } #ifdef XPG4_1994_04_09 ! if ((w == 52 ! && t->tm_mon == TM_JANUARY) ! || (w == 1 ! && t->tm_mon == TM_DECEMBER)) w = 53; #endif /* defined XPG4_1994_04_09 */ if (*format == 'V')
participants (2)
-
ado -
Paul Eggert