Subject: Re: bug#23270: Bug in 'date' command

From: Assaf Gordon <[email-masked]>
Date: Mon, 11 Apr 2016 14:11:19 -0400

tag 23270 notabug
close 23270
thanks

Hello Maarten Mastbroek,

On 04/11/2016 12:36 PM, Maarten wrote:
> I recently discovered a bug, or at least unexpected behavior, about
> the ‘date’ command which I want to report.  The bug is related to the
> moment of ‘daylight saving time’ (summertime / wintertime)

This is not a bug (perhaps indeed unexpected behavior).

It is explained in the Coreutils FAQ:
  http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e

Your diagnosis is correct:

> [...] When I request a ‘yesterday' request is about 24 hours before.

In GNU 'date', the relative period of 'yesterday' is defined exactly as 24 hours,
regardless of daylight saving time.

The recommended way to perform all relative day calculations is to specify 12:00pm,
so that adding/subtracting 24-hours avoids DST issues.

Example:
    date -d "12:00 yesterday"  +%d-%m-%Y

(similarly, when calculating relatives months, it is recommended to specify the 15th of the month, to avoid leap-years issues.)

As such I'm closing this bug, but discussion can continue by replying to this thread.

regards,
  - assaf