[PLUG] odd date command behavior for the starting Daylight time in a year

Daniel Hedlund daniel at digitree.org
Thu Sep 26 10:54:32 PDT 2013


On Wed, Sep 25, 2013 at 10:54 PM, Dale Snell <ddsnell at frontier.com> wrote:

> Those March days are all Daylight Saving Time switchover days, aren't
> they?  (If they're not, I'm going to look really stupid...)  There is
> no 2:00AM hour on those days, thus the dates really are invalid.
>

Dale is correct here in that they really aren't valid dates due to the
daylight savings change.  To compound the problem, dates between 01:00:00
and 01:59:59 are ambiguous if you don't specify a timezone.

date -d "Nov 7 01:59:59 2010" +%s # => 1289120399 (in PDT)
date -d "Nov 7 02:00:00 2010" +%s # => 1289124000 (in PST, +3601 epoc
seconds)

date -d "Nov 7 01:00:00 2010 PDT" +%s # => 1289116800
date -d "Nov 7 01:00:00 2010 PST" +%s # => 1289120400 (+3600 epoc seconds)


Working backwards from seconds since epoc (which is in UTC)...

date -d @1268560799 # => Sun Mar 14 01:59:59 PST 2010
date -d @1268560800 # => Sun Mar 14 03:00:00 PDT 2010 (+1 epoc second)

date -d @1289120399 # => Sun Nov  7 01:59:59 PDT 2010
date -d @1289120400 # => Sun Nov  7 01:00:00 PST 2010 (+1 epoc second)



More information about the PLUG mailing list