Subject: Re: bug#11125: date command calculations are not consistent

From: Eric Blake <[email-masked]>
Date: Thu, 29 Mar 2012 13:06:43 -0600

On 03/29/2012 12:34 PM, Thomas R. Schaefer wrote:

> In this case date is calculating with 24 hours days regardless of crossing a DST boundary..
> 
> [root@schaefer-test ~]# date -d "Thu Mar 22 00:00:00 CDT 2012 - 21 days"
> Wed Feb 29 23:00:00 CST 2012

This started from one fixed point in time, relative to the 'CDT' time
zone, and subtracted 21 * 24 hours.

> 
> In this case date does take DST into account in a relative date operation..
> 
> [root@schaefer-test ~]# date -d "last Thursday - 21 days"
> Thu Mar  1 00:00:00 CST 2012

But notice what date -d "last Thursday" is:

$ TZ=CST date -d 'last Thursday CST'
Thu Mar 22 00:00:00 CST 2012

It's relative to the 'CST' timezone, which is an hour different from the
CDT timezone.

> 
> If the date command where being consistent in following the consensus that "relative date operations add or subtract in multiples of 24 hours, without regards to daylight savings boundaries" then both of the above date commands would return Wed Feb 29 23:00:00 CST 2012.

Only if you start from the same point in time in both commands, which
you didn't.

-- 
Eric Blake   [email-masked]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org