GNU bug report logs - #11125
date command calculations are not consistent

Previous Next

Package: coreutils;

Reported by: "Thomas R. Schaefer" <schaefert <at> yahoo.com>

Date: Thu, 29 Mar 2012 18:21:01 UTC

Severity: normal

Tags: notabug

Merged with 11098, 11101, 15785, 18159, 18479, 20523

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 11125 <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: "Thomas R. Schaefer" <schaefert <at> yahoo.com>
Cc: 11125 <at> debbugs.gnu.org
Subject: Re: bug#11125: date command calculations are not consistent
Date: Thu, 29 Mar 2012 13:06:43 -0600
[Message part 1 (text/plain, inline)]
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 <at> 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 <at> 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   eblake <at> redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

This bug report was last modified 6 years and 211 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.