tz strftime %V week numbers are incompatible with Solaris, GNU

Paul Eggert eggert at twinsun.com
Fri Jul 26 16:11:48 UTC 1996


   Date: Wed, 17 Jul 96 14:18:59 EDT
   From: ado at 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')



More information about the tz mailing list