[tz] How to compute the moment of the next DST change

random832 at fastmail.us random832 at fastmail.us
Wed Apr 3 14:32:06 UTC 2013

On Wed, Apr 3, 2013, at 10:12, Boruch Baum wrote:
> A few months ago, I posted to this list (and posted source code to
> github https://github.com/Boruch-Baum/zdump-3-) a C function that I
> think will do what you all want. No heuristics or guessing.
> For the use case "compute the moment of the next DST change", pass to
> the function the current time/date as the start period, and a 'safe'
> date in the future (say one year hence). The second entry in the
> returned struct will be "moment of the next DST change".


> int zdump( char *tzname, const time_t start, const time_t end,
>           int* num_entries, void** return_data);

Why isn't return_data a struct zdumpinfo **?

> 	char   save_secs;
> The absolute value of the number of seconds that the \fIutc_offset\fP is at variance from the timezone's "standard time". Thus, this value will be zero if not daylight savings time. This value will be negative if this information not would not be available using the \fBlocaltime_r()\fP function.\

This field seems to actually be an int, contrary to the manpage. This
doesn't document the fact that it uses the previous entry (what happens
if the first entry returned is in DST?) as "standard time", which will
fail if the time zone itself changes at the same time as daylight
savings changes.

More information about the tz mailing list