Bug 6723 - mktime() unexpected behaviour if tm_isdst > 1
Summary: mktime() unexpected behaviour if tm_isdst > 1
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
Depends on:
Reported: 2008-07-06 17:52 UTC by Michael Ringe
Modified: 2014-07-04 05:50 UTC (History)
1 user (show)

See Also:
Target: Linux/i686
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Michael Ringe 2008-07-06 17:52:37 UTC
According to the mktime() manual page, a positive value of tm_isdst means that
DST is in effect. However, mktime() seems to check only for tm_isdst==1, while
any other positive value is treated as "no DST".

Consider this program:
    int i;
    for (i = 1; i <= 2; ++i) {
        struct tm tm;
        tm.tm_mday = 1;
        tm.tm_mon = 10;
        tm.tm_year = 108;
        tm.tm_isdst = i;
        time_t t = mktime(&tm);
        printf(" --> mktime()=%d isdst=%d\n",t,tm.tm_isdst);

When running e.g. with TZ=Europe/Berlin, the output is

   isdst=1 --> mktime()=1225490400 isdst=0
   isdst=2 --> mktime()=1225494000 isdst=0

Of course, the time in question is non-DST, and mktime correctly changes
tm_isdst to 0. But IMHO there are two issues here:

1. The manpage should make clear wether or not the DST offset is
   applied in cases like this (take a look, for example, into the  
   Solaris manpage)
2. All positive values of tm_isdst should produce the same result
Comment 1 Ulrich Drepper 2008-07-06 21:19:02 UTC
I changed the libc code but the man pages are a completely separate project.