Subject: bug#26101: Counterproductive calculation order in date

From: Eric Blake <[email-masked]>
Date: Wed, 15 Mar 2017 09:46:46 -0500

On 03/15/2017 08:43 AM, Ulf Zibis wrote:
> 
> Am 15.03.2017 um 13:44 schrieb Eric Blake:
>> Maybe you are confused on how date implements "subtract a month".  It
>> does NOT do "subtract 28, 29, 30, or 31 days as appropriate", but rather
>> does "subtract 30 days, for lack of anything better to do".
> 
> Are you really sure ???
> Here on my 8.25 version I get:
> $ date -d "-12 month" +%F
> 2016-03-15
> $ date -d "-360 day" +%F
> 2016-03-20

Interesting (it's been a while since I've tried that; so maybe we really
have made improvements in the meantime).  --debug output is pertinent:

$ src/date -d '-12 month' --debug
date: parsed relative part: -12 month(s)
date: input timezone: -06:00 (set from system default)
date: using current time as starting value: '09:41:25'
date: using current date as starting value: '(Y-M-D) 2017-03-15'
date: starting date/time: '(Y-M-D) 2017-03-15 09:41:25 TZ=-06:00'
date: after date adjustment (+0 years, -12 months, +0 days),
date:     new date/time = '(Y-M-D) 2016-03-15 09:41:25 TZ=-06:00'
...

vs.
$ src/date -d '-360 day' --debug
date: parsed relative part: -360 day(s)
date: input timezone: -06:00 (set from system default)
date: using current time as starting value: '09:41:32'
date: using current date as starting value: '(Y-M-D) 2017-03-15'
date: starting date/time: '(Y-M-D) 2017-03-15 09:41:32 TZ=-06:00'
date: warning: when adding relative days, it is recommended to specify
12:00pm
date: after date adjustment (+0 years, +0 months, -360 days),
date:     new date/time = '(Y-M-D) 2016-03-20 09:41:32 TZ=-06:00'

> 
> So I think my list for enhancements is still fully applicable.
> 
> -Ulf
> 
> PS: You may drop the copy to my personal email, so I don't get it twice,
> as I'm subscribed to the list.

List policy is to reply-to-all, so that we don't have to think about who
is subscribed, while making sure that even unsubscribed readers stay in
the loop on the message they are interested in.  The list server has
settings where you can request that you don't receive duplicate messages
(that is, the list won't send you a second copy of the mail if your
address was listed in to or cc); and you can also set mail-followup-to
when posting to help direct the behavior of reply-to-all when someone
replies to you.  It doesn't scale to make me and every other subscriber
special-case "which people that I'm replying to don't want a duplicate",
compared to you to just tweak settings on your end to avoid the
duplicates and/or set things up so that reply-to-all excludes you
because you prefer to get it through the list.

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