Subject: Re: bug#16386: maybe a small Bug in date?

From: Eric Blake <[email-masked]>
Date: Tue, 07 Jan 2014 10:10:58 -0700

tag 16386 notabug
thanks

On 01/07/2014 08:37 AM, [email-masked] wrote:
> Hello,
> 
> could this be a bug in date?

Thanks for the report.  However, this is not a bug in date, but a
misunderstanding on your part, covered in our FAQ.

https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e

> 
> OK:		date +%V_%Y -d "last wednesday" 		-> 01_2014

Do not mix %V and %Y.  %V goes with %G, %Y goes with %U or %W.

> OK: 		date +%V_%Y -d "last wednesday +1 week"	-> 02_2014
> ...
> OK: 		date +%V_%Y -d "last wednesday +51 week"	-> 52_2014
> WRONG:  	date +%V_%Y -d "last wednesday +52 week"	-> 01_2014
> This should be 01_2015:					            ^^^^

No, you are using the wrong format string.  When you mix two different
formats that use different notions of when a year rolls over, you are
bound to get confusing results.  But those results are correct, once you
re-read the documentation of what those format strings represent.

> Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte Informationen

This disclaimer is unenforceable on a publicly-archived mailing list.
It is considered poor email etiquette to open source lists to use your
employer's email if they are going to tack on garbage.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org