Submitter: Nick Stoughton (US)
Submission Date: 2014-05-08
Source: Austin Group
Reference Document: Austin Group Bug 739
Version: 1.1
Date: May 2014
Subject: strftime
%F equivalency
problems and number of digits for %Y
Summary
The C Standard normatively requires that for the strftime
function,
the "%F"
format specifier is equivalent to
"%Y-%m-%d"
. There is also an informational note (in parentheses) that
this is supposed to be the same as an ISO 8601 date. However, 8601 requires
years to be a minimum of 4 digits.
Given a year < 1000, how many digits does %Y produce? The normative text states
only "%Y is replaced by the year as a decimal number (e.g., 1997). [tm_year]"
.
POSIX, however, requires (as a C extension) that
"[CX] Equivalent to %+4[Option End]Y-%m-%d if no flag and no minimum field width
are specified. [ tm_year, tm_mon, tm_mday]"
(note, POSIX includes an extension
to specify field widths).
If %F is indeed intended to be a means to print ISO-8601 formatted dates, then %Y should always produce a minimum of 4 digits.
Suggested Change
EITHER: at 7.27.3.5 para 3, change:%Y is replaced by the year as a decimal number (e.g., 1997). [tm_year]to
%Y is replaced by by at least 4 digits of the year as a decimal number (e.g., 1997). [tm_year]
OR: at 7.27.3.5 para 3, change:
%F is equivalent to "%Y-%m-%d" (the ISO 8601 date format). [tm_year, tm_mon, tm_mday]to
%F is equivalent to "%Y-%m-%d", except that the year shall have a minimum of 4 digits (the ISO 8601 date format). [tm_year, tm_mon, tm_mday]
Committee Discussion
Proposed Technical Corrigendum