bug-coreutils
[Top][All Lists]
Advanced

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

bug#17374: issue with '/bin/date' resolving months via '-d DATESTR'


From: Leslie S Satenstein
Subject: bug#17374: issue with '/bin/date' resolving months via '-d DATESTR'
Date: Wed, 30 Apr 2014 11:57:12 -0700 (PDT)

Eric
Read the documentation.  When the previous month has 28/29 days and today is 
the 30th, the software goes to February 30, and finds it does not exist. The 
algorithm then bumps up the month and adds the difference between 28 and 30 to 
the day of the bumped up month. Therefore, according to the algorithm, the 
month after issuing /bin/date -d '*2 months ago*' +%B     becomes March.  
Had you included the day, you would see it to be the 2nd of March.




 
Regards 

 Leslie

Mr. Leslie Satenstein
SENT FROM MY OPEN SOURCE LINUX SYSTEM.




>________________________________
> From: Eric Blake <address@hidden>
>To: Benjamin Richardson <address@hidden>; address@hidden 
>Sent: Tuesday, April 29, 2014 6:30 PM
>Subject: bug#17374: issue with '/bin/date' resolving months via '-d DATESTR'
> 
>
>tag 17374 notabug
>thanks
>
>On 04/29/2014 02:17 PM, Benjamin Richardson wrote:
>> Hello,
>> 
>> I think my issue can best be described by demonstration. Here goes:
>
>Thanks for the report and demonstration.
>
>
>> 
>> address@hidden /bin/date
>> Tue Apr 29 15:51:11 EDT 2014
>> address@hidden /bin/date -d 'last month' +%B
>> March
>> address@hidden /bin/date -d '*2 months ago*' +%B
>> *March*
>> address@hidden /bin/date -d '3 months ago' +%B
>> January
>> 
>> I expected 2 months ago to be February, not March. I get that Feb 29
>> doesn't exist, so returning a date that never happened might not make
>> sense. But in simply asking for the month, not the full date of 2 months
>> ago, could %B be calculated first, before rolling over to March 1st?
>
>You have asked a FAQ:
>
>https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e
>
>While it might be feasible to tweak the hueristics of how to roll over a
>non-uniform chunk of time, it is almost certain that doing so will also
>break existing uses that have come to rely on the current behavior of
>treating relative months as a multiple of 30 days.  Similar problems
>occur when trying to deal with how to deal with 23- and 25-hour days
>around daylight savings, when moving by relative chunks of "days" which
>are typically 24 hours.
>
>The FAQ describes how to do calculations relative to the 15th of a month
>(or to noon for a day) so as to eliminate the chance of fuzzy hueristics
>plopping you on a point in time you weren't expecting, but which is
>still valid in terms of the math performed when you actually stop and
>think about what was done.  As this is already documented, I'm not sure
>there is much else we can do in the code base.  Therefore, I'm closing
>this bug, although you should feel free to add more comments or even
>better propose patches.
>
>-- 
>Eric Blake   eblake redhat com    +1-919-301-3266
>Libvirt virtualization library http://libvirt.org
>
>
>
>


reply via email to

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