Subject: Bug in 'date' command

From: Maarten <[email-masked]>
Date: Mon, 11 Apr 2016 18:36:01 +0200

Hello,

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)

On Monday the 28st of march at 0.15 I run an automated script with the command:

# date -d yesterday +%d-%m-%Y

The return of that command was 26-03-2016 where I expected 27-03-2016. (2 days before, where I expected only 1 day before)

My only explanation is that the command is run the day after 27-3-2016, the day that the our region switched from summertime to wintertime.  At 2.00 the clock is forwarded to 3.00 so the day is only 23 hours long. When I request a ‘yesterday at 28-03-20160.15 the request is about 24 hours before.  The answer is 26-03-2016 at 23.15.

Anyway, a ‘date -d yesterday’ should return 1 day before, not 2 days before.  In my case, as a result of it, an automated shell script went wrong.

Please, can you fix this ‘daylight saving time’ related bug?

More info:

Timezone: Amsterdam, europe

# cat /etc/redhat-release

Red Hat Enterprise Linux Server release 6.7 (Santiago)

# date --version

date (GNU coreutils) 8.4

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.

Many thanks!  If you need further information, please let me know.

Best regards,

Maarten Mastbroek