bug-coreutils
[Top][All Lists]
Advanced

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

bug#11125: date command calculations are not consistent


From: Eric Blake
Subject: bug#11125: date command calculations are not consistent
Date: Thu, 29 Mar 2012 13:06:43 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120316 Thunderbird/11.0

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..
> 
> address@hidden ~]# 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..
> 
> address@hidden ~]# 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   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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