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: Thomas R. Schaefer
Subject: bug#11125: date command calculations are not consistent
Date: Thu, 29 Mar 2012 10:43:39 -0700 (PDT)

Discovered this when I script I have cronned to run at 12:01AM gave some 
unexpected results.

After much picking at it I finally figured out that the date command itself was 
the source of my problem.  It isn't handling date calculations that span the 
daylight savings time change consistently..

address@hidden ~]$ date --version
date (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by David MacKenzie.
address@hidden ~]$ date -d "last Thursday"
Thu Mar 22 00:00:00 CDT 2012
address@hidden ~]$ date -d "Thu Mar 22 00:00:00 CDT 2012"
Thu Mar 22 00:00:00 CDT 2012
address@hidden ~]$ date -d "last Thursday - 21 days"
Thu Mar  1 00:00:00 CST 2012
address@hidden ~]$ date -d "Thu Mar 22 00:00:00 CDT 2012 - 21 days"
Wed Feb 29 23:00:00 CST 2012

In my real world case I was running a script at 12:01AM on Sundays that did 
this..

RSD="$(date +%F -d "today - 35  days")" # Report Start Date

RSD was getting set to a Saturday date but ordinarily, when a DST change hasn't 
occurred in the past 35 days, it would be set to a Sunday date.  I expect and 
want the Sunday date regardless; although I realize an argument could be made 
for the correctness of the Saturday date too.  However the date command is 
going to make a calculation like that it should be consistent with its own self 
which if you look closely at my examples above regarding last Thursday you will 
see it is not consistent with itself.

Thank you,
Tom Schaefer




reply via email to

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