date: improve doc for ambiguous formats

Problem reported by Tim Connors <https://bugs.gnu.org/75208>.
* doc/coreutils.texi (Date conversion specifiers):
* src/date.c (usage):
Warn about ambiguous formats like %D.
This commit is contained in:
Paul Eggert
2024-12-30 11:38:56 -08:00
parent 9eb131e530
commit a0c3e5648b
2 changed files with 13 additions and 8 deletions

View File

@@ -16656,7 +16656,9 @@ It is normally at least two characters, but it may be more.
@item %d
day of month (e.g., @samp{01})
@item %D
date; same as @samp{%m/%d/%y}
date; same as @samp{%m/%d/%y}.
Although commonly used in the US, this format is confusing elsewhere,
and it is ambiguous for dates in different centuries.
@item %e
day of month, space padded; same as @samp{%_d}
@item %F
@@ -16672,6 +16674,7 @@ year corresponding to the ISO week number, but without the century
as @samp{%y}, except that if the ISO week number (see
@samp{%V}) belongs
to the previous or next year, that year is used instead.
This format is ambiguous for dates in different centuries.
@item %G
year corresponding to the ISO week number. This has the
same format and value as @samp{%Y}, except that if the ISO
@@ -16710,9 +16713,11 @@ week number of year, with Monday as first day of week
(@samp{00}@dots{}@samp{53}).
Days in a new year preceding the first Monday are in week zero.
@item %x
locale's date representation (e.g., @samp{12/31/99})
locale's date representation (e.g., @samp{12/31/99}).
This format can be ambiguous for dates in different centuries.
@item %y
last two digits of year (@samp{00}@dots{}@samp{99})
last two digits of year (@samp{00}@dots{}@samp{99}).
This format is ambiguous for dates in different centuries.
@item %Y
year. This is normally at least four characters, but it may be more.
Year @samp{0000} precedes year @samp{0001}, and year @samp{-001}

View File

@@ -200,13 +200,13 @@ FORMAT controls the output. Interpreted sequences are:\n\
fputs (_("\
%C century; like %Y, except omit last two digits (e.g., 20)\n\
%d day of month (e.g., 01)\n\
%D date; same as %m/%d/%y\n\
%D date (ambiguous); same as %m/%d/%y\n\
%e day of month, space padded; same as %_d\n\
"), stdout);
fputs (_("\
%F full date; like %+4Y-%m-%d\n\
%g last two digits of year of ISO week number (see %G)\n\
%G year of ISO week number (see %V); normally useful only with %V\n\
%g last two digits of year of ISO week number (ambiguous; 00-99); see %G\n\
%G year of ISO week number; normally useful only with %V\n\
"), stdout);
fputs (_("\
%h same as %b\n\
@@ -243,9 +243,9 @@ FORMAT controls the output. Interpreted sequences are:\n\
%W week number of year, with Monday as first day of week (00..53)\n\
"), stdout);
fputs (_("\
%x locale's date representation (e.g., 12/31/99)\n\
%x locale's date (can be ambiguous; e.g., 12/31/99)\n\
%X locale's time representation (e.g., 23:13:48)\n\
%y last two digits of year (00..99)\n\
%y last two digits of year (ambiguous; 00..99)\n\
%Y year\n\
"), stdout);
fputs (_("\