Коллеги, есть вот такой код на C:
#include <time.h>
#include <stdio.h>
int main() {
time_t t;
struct tm tm1;
tzset();
time(&t);
localtime_r(&t, &tm1);
printf("\n now:\t\t\t(%d) %s", t, asctime(&tm1));
tm1.tm_mday = 26;
tm1.tm_sec = 59;
tm1.tm_min = 59;
tm1.tm_hour = 1;
tm1.tm_mon = 9;
t = mktime(&tm1);
printf(" tm_hour = 1:\t\t(%d) %s", 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 = 0:\t\t(%d) %s", t, asctime(&tm1));
t += 3602;
localtime_r(&t, &tm1);
printf(" 3602 seconds later:\t(%d) %s", t, asctime(&tm1));
t -= 3604;
localtime_r(&t, &tm1);
printf(" 3604 seconds before:\t(%d) %s\n", t, asctime(&tm1));
}
На RHEL с tzdata 2014h получаем ожидаемые результаты:
now: (1413448301) Thu Oct 16 12:31:41 2014
tm_hour = 1: (1414277999) Sun Oct 26 01:59:59 2014
tm_hour = 0: (1414270799) Sun Oct 26 00:59:59 2014
3602 seconds later: (1414274401) Sun Oct 26 01:00:01 2014
3604 seconds before: (1414270797) Sun Oct 26 00:59:57 2014
На Solaris 11.2 c timezone 2014f получаем какой то ад:
now: (1413447693) Thu Oct 16 12:21:33 2014
tm_hour = 1: (1414277999) Sun Oct 26 01:59:59 2014
tm_hour = 0: (1414274399) Sun Oct 26 01:59:59 2014
3602 seconds later: (1414278001) Sun Oct 26 02:00:01 2014
3604 seconds before: (1414274397) Sun Oct 26 01:59:57 2014
Традиционный вопрос, что я делаю не так?