GNU bug report logs -
#11125
date command calculations are not consistent
Previous Next
Full log
View this message in rfc822 format
[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 210 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.