bug-coreutils
[Top][All Lists]
Advanced

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

bug#23008: Daylight Savings Time Bug in Date


From: Eric Blake
Subject: bug#23008: Daylight Savings Time Bug in Date
Date: Mon, 14 Mar 2016 09:04:16 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

tag 23008 notabug
thanks

On 03/13/2016 11:24 PM, Sarah Corriher wrote:
> We detected a bug in the date program, which correlates to the daylight
> savings time change.

Thanks for the report.  However, this is not a bug, but a FAQ that gets
asked twice a year.  See:

https://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e

> 
>    $ date -d -0days +%Y-%m-%d
>    2016-03-14
> 
>    $ date -d -1days +%Y-%m-%d
>    2016-03-12

When trying to add units of 24 hours (the -1days), only to then display
just a day and not an hour, it's best to start from noon rather than
from a time that might be impacted by daylight savings:

# date -d '12:00pm 2014-03-14 -1day' +%Y-%m-%d
2016-03-13

Otherwise, as you discovered, starting at midnight and going 24 hours
across a day with only 23 hours is likely to skip that day.

I'm closing this as not a bug, but feel free to reply with further
questions or comments.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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