I get Starting datetime is 2020-03-08 01:00:00 Represented as a time tuple, this is time.struct_time(tm_year=2020, tm_mon=3, tm_mday=8, tm_hour=1, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=68, tm_isdst=-1) After adding an hour, the resultant datetime is 2020-03-08 02:00:00 Represented as a timetuple this is time.struct_time(tm_year=2020, tm_mon=3, tm_mday=8, tm_hour=2, tm_min=0, tm_sec=0, tm_wday=6, tm_yday=68, tm_isdst=-1) Traceback (most recent call last): File "./test.py", line 22, in <module> ts = time.mktime(tt1) OverflowError: mktime argument out of range
I wrote a test program for mktime. With the isdst/gmtoff values from localtime, it works. With this, I can provoke EINVAL, which I think is per the spec. ---------------------------------------- #include <errno.h> #include <stdio.h> #include <time.h> int main() { struct tm *t; time_t start = 1583647200; /* 20200308T0100 EST */ time_t plus1; t = localtime(&start); printf("isdst %d tm_gmtoff %ld\n", t->tm_isdst, t->tm_gmtoff); t->tm_isdst = -1; t->tm_gmtoff = 0; printf("isdst %d tm_gmtoff %ld\n", t->tm_isdst, t->tm_gmtoff); t->tm_hour += 1; printf("tm_hour %d\n", t->tm_hour); plus1 = mktime(t); printf("plus1 %jd errno %d\n", (intmax_t) plus1, errno); printf("result: %s\n", plus1 == 1583650800 ? "ok" : "bad"); return 0; } ---------------------------------------- isdst 0 tm_gmtoff -18000 isdst -1 tm_gmtoff 0 tm_hour 2 plus1 -1 errno 22 result: bad -- You received this message because you are subscribed to the Google Groups "weewx-development" group. To unsubscribe from this group and stop receiving emails from it, send an email to weewx-development+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/rmi4kuxqc7g.fsf%40s1.lexort.com.