OK, so we've isolated the issue to a problem with how NetBSD implements time.mktime().
I suppose we could trap the exception in intervalgen() and, instead, return the simple arithmetic result of adding increment. Something like: delta = datetime.timedelta(seconds=interval) last_stamp1 = 0 while dt1 < stop_dt: dt2 = min(dt1 + delta, stop_dt) stamp1 = int(time.mktime(dt1.timetuple())) try: stamp2 = int(time.mktime(dt2.timetuple())) except OverflowError: stamp2 = stamp1 + interval if stamp2 > stamp1 > last_stamp1: yield TimeSpan(stamp1, stamp2) last_stamp1 = stamp1 dt1 = dt2 On Mon, Mar 9, 2020 at 5:35 PM Greg Troxel <g...@lexort.com> wrote: > 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/CAPq0zEB8H%2BNw_u99vN3D00pFn4HWkp1t3B3eChauPA5v8ba_-w%40mail.gmail.com.