suggested improvements for C9x `New formats for strftime()' (N733)
Antoine Leca
Antoine.Leca at renault.fr
Mon Jul 7 09:12:06 UTC 1997
Paul Eggert wrote:
>
> You propose new conversion specifiers for strftime in C9x, the new C standard,
> in your document ISO/IEC JTC1/SC22/WG14 N733
> <http://www.gold.net/users/cdwf/c/wg14n733.txt> (1997-07-01).
I noticed another doc, N735, about wider changes in the library.
<URL:http://www.gold.net/users/cdwf/c/wg14n735.txt> (1997-07-04).
Item 20-25 (at the end) are relevant to the date and time functions.
In particular, Item 22 is relevant to the same problem Paul quoted.
In N733, Paul read
> %V is replaced by the ISO 8601 week number of the year
Clive's document add that the admissible range is [00-53].
It should be put in relief that N735 adds:
%#W - ISO 8601 week number ) If %W would be zero, the date is
%#y - ISO 8601 week number year % 100 ) treated as belonging to week 53
%#Y - ISO 8601 week number year ) of the previous year
(Note: it could be week *52* of the previous year).
I read this the following way (this is nothing official):
For Tuesday 1996-12-31, we should have:
%y 96
%U 52
%W 52
%V 53
%#W 01 the correct ISO 8601 week
%#y 97 the correct ISO 8601 year associated with the week number
For Friday 1999-01-01, we should have:
%y 99
%U 00
%W 00
%V 00
%#W 53 the correct ISO 8601 week
%#y 98 the correct ISO 8601 year associated with the week number
For Sunday 1999-01-03, we should have:
%y 99
%U 01
%W 00
%V 00
%#W 53 still in the previous year
%#y 98
For the fun, I add Saturday 2000-01-01:
%y 00 but still in the 20th century !
%U 00
%W 00
%V 00
%#W 53
%#y 99
> To work around this shortcoming, I propose that C9x add Robbins's
> %G and %g formats, as follows:
>
> %G is replaced by the year containing the ISO 8601 week
> %g is replaced by %G modulo 100
So %G is the same as %#Y, and %g the same as %#y.
But as I showed before, there is a difference between %V, showing
the week number _in_the_year_ based on Monday, the first Thrusday
being in week 01 (and thus able to be 00), and the real ISO 8601
week number, %#W (restricted in range to 01-53).
So we probably need two specifiers, instead of one in current art.
I remember a discussion some time ago in the tz list about this:
in particular, some point as strange to have a week number like
53 at the beginning of the year, or a low number at the end...
Antoine
More information about the tz
mailing list