[Top][All Lists]

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

Date command not returning proper relative time on DST boundary cross ov

From: Jakub Luzny
Subject: Date command not returning proper relative time on DST boundary cross over
Date: Tue, 4 Aug 2015 17:49:02 -0400 (EDT)


I would like to fix the issue described here: 

There is a problem that date is using the tm_isdst settings from the present 
time got by gettimeofday(). This behavior is wrong when the relative time 
offset causes transition to/from DST time. 

The easy fix is to change parse_datetime.y:1342 from

> tm.tm_isdst = tmp->tm_isdst;


>   tm.tm_isdst = -1;

As written in mktime(3): 
>  negative value means that mktime() should (use timezone information and 
> system databases to) attempt to determine whether DST is in effect at the 
> specified time.

This behavior is maybe not fully correct (why?), because it was removed 
and added later for absolute timestamps: 

I could't find anything about the bug referenced in the first commit.

The issue can be easily simulated using faketime utility:

$ LANG=C TZ=EST5EDT faketime  '2013-03-11 0:15:00' /bin/date -d "1 day ago"
Sat Mar  9 23:15:00 EST 2013

So, I would like to ask: why is it wrong to use -1 for time_isdst, and why it 
is correct for absolute timestamps? I tried to get some wrong behaviour after 
the change, but didn't got any. Maybe I didn't try enough. All tests passed.

Any tips on how this could be done better are welcome.


reply via email to

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