GNU bug report logs -
#11098
date --yesterday wrong result
Previous Next
Full log
Message #13 received at 11098-done <at> debbugs.gnu.org (full text, mbox):
Hi Eric,
Thank you for this answer. My excpectations are not buged! ;) When
someone ask me to tell him what is yesterday, even if we are early in
the morning, I answer him the day before and not two days ago.
I already know how to work around this problem. Anyway, I'd like to
thank you for the link to you're FAQ and for your quick answer.
Best regards,
Hugo
Le 26 mars 2012 à 19:31, Eric Blake <eblake <at> redhat.com> a écrit :
> tag 11098 notabug
> thanks
>
> On 03/26/2012 05:31 AM, Hugo Guérineau wrote:
>> Dear Mister, Madam,
>>
>> I'm writing to report a date computation problem.
>>
>> The command "date --date='yesterday' +%Y-%m-%d" launched this morning
>> between 0:00 am and 0:59 am gives the wrong result:
>>
>> root <at> serveur:> date --date='today' +%Y-%m-%d; date --date='yesterday'
>> +%Y-%m-%d
>> 2012-03-26
>> 2012-03-24
>>
>> This is caused by the system clock changes which happened last night.
>
> Thanks for the report. However, this is not a bug in date, but in your
> expectations. 'yesterday' translates to '24 hours ago', and due to your
> daylight savings swap, 24 hours ago really does put you into a different
> date. As recommended in our FAQ,
>
> https://www.gnu.org/software/coreutils/faq/#The-date-command-is-not-working-right_002e
>
> it's almost always better to base relative time computations off of noon
> rather than midnight (as both 11 am and 1 pm fall in the same day, even
> when your multiple-of-24-hours crosses a 23-hour or 25-hour day).
>
> --
> Eric Blake eblake <at> redhat.com +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
This bug report was last modified 6 years and 209 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.