Strange mktime behavior in Solaris 11.2, bug or something else?

Sounds like an error, first take a look at the code:

#include <time.h>
#include <stdio.h>

int main() {

    time_t t;
    struct tm tm1;

    tzset();

    time(&t);
    localtime_r(&t, &tm1);

    tm1.tm_mday = 27;
    tm1.tm_sec = 59;
    tm1.tm_min = 59;
    tm1.tm_hour = 0;
    tm1.tm_mon = 9;

    t = mktime(&tm1);
    printf(" tm_hour = %d:\t\t(%d) %s", tm1.tm_hour, t, asctime(&tm1));

    tm1.tm_mday = 26;
    tm1.tm_sec = 59;
    tm1.tm_min = 59;
    tm1.tm_hour = 0;
    tm1.tm_mon = 9;

    t = mktime(&tm1);
    printf(" tm_hour = %d:\t\t(%d) %s", tm1.tm_hour, t, asctime(&tm1));

}

I believe that it will work as follows:

     $ ./tzcheck3
     tm_hour = 0: (1414360799) Mon Oct 27 00:59:59 2014
     tm_hour = 0: (1414270799) Sun Oct 26 00:59:59 2014

Instead, I have this:

     $ ./tzcheck3
     tm_hour = 0: (1414360799) Mon Oct 27 00:59:59 2014
     tm_hour = 1: (1414274399) Sun Oct 26 01:59:59 2014

The installed OS is Solaris 11.2.2.8.0 + IDR 1418.1, the time zone data is 2014f, here is the zdump time zone:

    # zdump -v Europe / Moscow | tail -10
    Europe / Moscow Sat Mar 27 22:59:59 2010 UTC = Sun Mar 28 01:59:59 2010 MSK isdst = 0
    Europe / Moscow Sat Mar 27 23:00:00 2010 UTC = Sun Mar 28 03:00:00 2010 MSD isdst = 1
    Europe / Moscow Sat Oct 30 22:59:59 2010 UTC = Sun Oct 31 02:59:59 2010 MSD isdst = 1
    Europe/Moscow  Sat Oct 30 23:00:00 2010 UTC = Sun Oct 31 02:00:00 2010 MSK isdst=0
    Europe/Moscow  Sat Mar 26 22:59:59 2011 UTC = Sun Mar 27 01:59:59 2011 MSK isdst=0
    Europe/Moscow  Sat Mar 26 23:00:00 2011 UTC = Sun Mar 27 03:00:00 2011 MSK isdst=0
    Europe/Moscow  Sat Oct 25 21:59:59 2014 UTC = Sun Oct 26 01:59:59 2014 MSK isdst=0
    Europe/Moscow  Sat Oct 25 22:00:00 2014 UTC = Sun Oct 26 01:00:00 2014 MSK isdst=0
    Europe/Moscow  Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 06:14:07 2038 MSK isdst=0
    Europe/Moscow  Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 06:14:07 2038 MSK isdst=0

, Sun Oct 26 02:00, , mktime 01:59 00:59 .

?

+4
source share

All Articles