bug-coreutils
[Top][All Lists]
Advanced

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

Re: bug about date


From: Philip Rowlands
Subject: Re: bug about date
Date: Mon, 8 Mar 2010 09:36:42 +0000 (GMT)
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)

On Mon, 8 Mar 2010, gaosh wrote:

I use the command: date +%Y%m%d%H -d "1990-04-13 12 36 hours"
But I get the result: 1990041501 ! The correct one should be 1990041500.

The result depends on your system's local timezone, which I assume is set to Asia/Shanghai or equivalent Chinese location. 1990-04-14 was a day when daylight saving time began, so you're seeing the extra hour gained. This is more obvious if you use the %z display option to see the UTC offset:

$ TZ=Asia/Shanghai date '+%Y%m%d%H %z' -d '1990-04-13 12 35 hours'
1990041423 +0800
$ TZ=Asia/Shanghai date '+%Y%m%d%H %z' -d '1990-04-13 12 36 hours'
1990041501 +0900

So this is not a bug, but a hazard of making precise date calculations around DST boundaries. Please read the FAQ discussion here:
http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#The-date-command-is-not-working-right_002e


Cheers,
Phil




reply via email to

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