bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date bug


From: Paul Eggert
Subject: Re: date bug
Date: Mon, 02 Jan 2006 16:49:52 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

William Johnson <address@hidden> writes:

> I have run this script on my linux router and in cygwin.
> In both cases, the date is changed from 2006 to 2005.

The output is correct.  %G corresponds to %V, and so Sunday January 1
is considered to be in the previous year (2005, in this case).

You probably want %Y instead of %G.

I installed this patch to the documentation to try to clarify things
a bit better.

2006-01-02  Paul Eggert  <address@hidden>

        * doc/coreutils.texi: Use @acronym around "ISO" uniformly.
        (Date conversion specifiers): Explain %g, %G, and %V a bit better.
        * src/date.c (usage): Explain %g, %G, and %V a bit better.

Index: doc/coreutils.texi
===================================================================
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.305
diff -p -u -r1.305 coreutils.texi
--- doc/coreutils.texi  2 Jan 2006 07:29:24 -0000       1.305
+++ doc/coreutils.texi  3 Jan 2006 00:41:24 -0000
@@ -4170,7 +4170,7 @@ processing.
 
 @c FIXME:  People don't necessarily know what an IBM-PC was these days.
 As it is set up now, the program assumes that the input file is coded
-using 8-bit ISO 8859-1 code, also known as Latin-1 character set,
+using 8-bit @acronym{ISO} 8859-1 code, also known as Latin-1 character set,
 @emph{unless} it is compiled for MS-DOS, in which case it uses the
 character set of the address@hidden  (@sc{gnu} @command{ptx} is not known to 
work on
 smaller MS-DOS machines anymore.)  Compared to 7-bit @acronym{ASCII}, the set
@@ -9620,8 +9620,10 @@ digits) specifying a character to print.
 @cindex Unicode
 @cindex ISO/IEC 10646
 @vindex LC_CTYPE
address@hidden interprets two character syntaxes introduced in ISO C 99:
address@hidden for 16-bit Unicode (ISO/IEC 10646) characters, specified as
address@hidden interprets two character syntaxes introduced in
address@hidden C 99:
address@hidden for 16-bit Unicode (@acronym{ISO}/@acronym{IEC} 10646)
+characters, specified as
 four hexadecimal digits @var{hhhh}, and @samp{\U} for 32-bit Unicode
 characters, specified as eight hexadecimal digits @var{hhhhhhhh}.
 @command{printf} outputs the Unicode characters
@@ -9645,7 +9647,7 @@ $ /usr/local/bin/printf '\u20AC 14.95'
 
 @noindent
 will be output correctly in all locales supporting the Euro symbol
-(ISO-8859-15, UTF-8, and others).  Similarly, a Chinese string
+(@acronym{ISO}-8859-15, UTF-8, and others).  Similarly, a Chinese string
 
 @example
 $ /usr/local/bin/printf '\u4e2d\u6587'
@@ -11858,22 +11860,27 @@ date; same as @samp{%m/%d/%y}
 @item %e
 day of month, space padded; same as @samp{%_d}
 @item %F
-full date in @w{ISO 8601} format; same as @samp{%Y-%m-%d}.
+full date in @acronym{ISO} 8601 format; same as @samp{%Y-%m-%d}.
 This is a good choice for a date format, as it is standard and
 is easy to sort in the usual case where years are in the range
 address@hidden
 This is a @acronym{GNU} extension.
 @item %g
-The year corresponding to the ISO week number, but without the century
+year corresponding to the @acronym{ISO} week number, but without the century
 (range @samp{00} through @samp{99}).  This has the same format and value
-as @samp{%y}, except that if the ISO week number (see @samp{%V}) belongs
+as @samp{%y}, except that if the @acronym{ISO} week number (see
address@hidden) belongs
 to the previous or next year, that year is used instead.
 This is a @acronym{GNU} extension.
 @item %G
-The year corresponding to the ISO week number.  This has the same format
-and value as @samp{%Y}, except that if the ISO week number (see
+year corresponding to the @acronym{ISO} week number.  This has the
+same format and value as @samp{%Y}, except that if the @acronym{ISO}
+week number (see
 @samp{%V}) belongs to the previous or next year, that year is used
 instead.
+It is normally useful only if @samp{%V} is also used;
+for example, the format @samp{%G-%m-%d} is probably a mistake,
+since it combines the ISO week number year with the conventional month and day.
 This is a @acronym{GNU} extension.
 @item %h
 same as @samp{%b}
@@ -11884,11 +11891,12 @@ month (@address@hidden@samp{12})
 @item %u
 day of week (@address@hidden@samp{7}) with @samp{1} corresponding to Monday
 @item %U
-week number of year with Sunday as first day of week
+week number of year, with Sunday as the first day of the week
 (@address@hidden@samp{53}).
 Days in a new year preceding the first Sunday are in week zero.
 @item %V
-week number of year with Monday as first day of the week as a decimal
address@hidden week number, that is, the
+week number of year, with Monday as the first day of the week
 (@address@hidden@samp{53}).
 If the week containing January 1 has four or more days in
 the new year, then it is considered week 1; otherwise, it is week 53 of
@@ -11897,7 +11905,7 @@ standard.)
 @item %w
 day of week (@address@hidden@samp{6}) with 0 corresponding to Sunday
 @item %W
-week number of year with Monday as first day of week
+week number of year, with Monday as first day of week
 (@address@hidden@samp{53}).
 Days in a new year preceding the first Monday are in week zero.
 @item %x
Index: src/date.c
===================================================================
RCS file: /fetish/cu/src/date.c,v
retrieving revision 1.160
diff -p -u -r1.160 date.c
--- src/date.c  16 Sep 2005 08:08:00 -0000      1.160
+++ src/date.c  3 Jan 2006 00:41:24 -0000
@@ -173,8 +173,8 @@ specifies Coordinated Universal Time.  I
 "), stdout);
       fputs (_("\
   %F   full date; same as %Y-%m-%d\n\
-  %g   the last two digits of the year corresponding to the %V week number\n\
-  %G   the year corresponding to the %V week number\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\
 "), stdout);
       fputs (_("\
   %h   same as %b\n\
@@ -204,10 +204,10 @@ specifies Coordinated Universal Time.  I
   %u   day of week (1..7); 1 is Monday\n\
 "), stdout);
       fputs (_("\
-  %U   week number of year with Sunday as first day of week (00..53)\n\
-  %V   week number of year with Monday as first day of week (01..53)\n\
+  %U   week number of year, with Sunday as first day of week (00..53)\n\
+  %V   ISO week number, with Monday as first day of week (01..53)\n\
   %w   day of week (0..6); 0 is Sunday\n\
-  %W   week number of year with Monday as first day of week (00..53)\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\




reply via email to

[Prev in Thread] Current Thread [Next in Thread]