severity 809789 normal tag 809789 + moreinfo thanks Brendan Reilly wrote: > Dear Maintainer,
I am not the gawk maintainer but in this just another awk user.
However I recognize this as being a misunderstanding of %G.
> %G returns the date as 2015 It is 2016
%G does not return the current year. G returns the year of the ISO
week number. The ISO week number year is 2015 for the 1st and 2nd of
January 2016. The ISO 8601 definition for the first week is the week
with the year's first Thursday in it.
December 2015
Su Mo Tu We Th Fr Sa
1 2 3 4 5 2015
6 7 8 9 10 11 12 2015
13 14 15 16 17 18 19 2015
20 21 22 23 24 25 26 2015
27 28 29 30 31 1 2 2015
3 4 5 6 7 8 9 2016 first Thursday
10 11 12 13 14 15 16 2016
17 18 19 20 21 22 23 2016
24 25 26 27 28 29 30 2016
31 2016
This is actually an FAQ for 'date' which uses the same format options.
This is not a bug. This is simply a misunderstanding of %G which
apparently is not what you want.
https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e
At the change of the year there are always many bug reports concerning
date behaving incorrectly. This is usually due to people using a
mismatch of ISO and legacy date format specifiers.
$ date -d 2008-12-31 +%Y%V
200801
$ date -d 2008-12-31 "+%G-%m-%d"
2009-12-31
The %Y and %U or %W options work in combination. (Use %U for weeks
starting with Sunday or %W for weeks starting with Monday.) The ISO %G
and %V options work in combination. Mixing them up creates
confusion. Instead use %Y and %U/%W together or use %G and %V
together.
$ date -d 2008-12-31 +%G%V
200901
$ date -d 2009-01-01 +%G%V
200901
$ date -d 2008-12-31 +%Y%U
200852
$ date -d 2009-01-01 +%Y%U
200900
Use of ISO week numbers tends to create confusion. The ISO week
numbering scheme is somewhat different from calendar week
numbering. ISO week numbers start on Monday of the week with the
year’s first Thursday in it. See Wikipidia’s ISO 8601 page
(http://en.wikipedia.org/wiki/ISO_8601) or Wikipidia’s ISO week date
page (http://en.wikipedia.org/wiki/ISO_week_date) for a good summary.
ISO Week Dates can be created using the following format.
$ date -d "2009-01-07 12:00:00 +0000" "+%G-W%V-%u"
2009-W02-3
See the standards documentation
(http://www.opengroup.org/onlinepubs/9699919799/utilities/date.html)
for more information with regards to date.
Does this resolve your issue?
Bob
signature.asc
Description: PGP signature

