Bug 27399

Summary: date(1) does not do daylight conversions properly
Product: Base System Reporter: Crist Clark <crist.clark>
Component: binAssignee: ru <ru>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.3-STABLE   
Hardware: Any   
OS: Any   

Description Crist Clark 2001-05-17 02:30:00 UTC
        The date(1) command does not properly deal with crossing
standard-daylight time boundaries. The _current_ daylight setting is
used rather than the one for the time the user provides. For example,
the switch to daylight time for my timezone (Pacific US) happened on
the morning of April 1st this year,

        $ date -j 200104010000
        Sat Mar 31 23:00:00 PST 2001
        $ date -j 200104020000
        Mon Apr  2 00:00:00 PDT 2001

As shown, when I want date to print the time for Sun Apr  1 00:00:00
PST 2001, it actually prints the time from an hour earlier. This is
not what the user would expect. Why should the current daylight
setting affect anything?

Fix: The date(1) command should let mktime(3) figure out the
daylight setting for the time it is given rather than using the
current daylight setting.




+       /* Let mktime(3) out if the provided date is in daylight time */
+       lt->tm_isdst = -1;
+
        /* convert broken-down time to GMT clock time */
        if ((tval = mktime(lt)) == -1)
                errx(1, "nonexistent time");--bmCqKqGwrlMUcHCPUyxuzyBipTzRLL9ssQQ5SQR4308Yglgr
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- date.c.orig Sat Sep 23 04:25:12 2000
+++ date.c      Wed May 16 16:44:59 2001
@@ -268,6 +268,9 @@
                }
        }
How-To-Repeat:         See above example.
Comment 1 ru freebsd_committer freebsd_triage 2001-05-17 16:20:22 UTC
State Changed
From-To: open->analyzed

Committed into -CURRENT, thanks! 


Comment 2 ru freebsd_committer freebsd_triage 2001-05-17 16:20:22 UTC
Responsible Changed
From-To: freebsd-bugs->ru

I'll MFC shortly.
Comment 3 ru freebsd_committer freebsd_triage 2001-05-20 12:45:58 UTC
State Changed
From-To: analyzed->closed

MFC'ed.