[tz] offtime_r
Paul Eggert
eggert at cs.ucla.edu
Wed Apr 26 21:00:10 UTC 2023
On 2023-04-26 02:18, Dag-Erling Smørgrav wrote:
> - although the same effect can be achieved with localtime_rz(), it
> requires quite a bit of setup.
Although localtime_rz requires setup, I'm not sure I'd call it "quite a
bit" of setup. Using localtime_rz:
timezone_t tz = tzalloc("MST7");
localtime_rz(tz, ×tamp, &tmstruct);
is not that much more complicated than using offtime_r would be:
offtime_r(×tamp, -7 * 60 * 60, &tmstruct);
although admittedly the localtime_rz case should eventually call tzfree.
Plus, offtime_r would share offtime's error-proneness with
abbreviations, as it would set tm.tm_zone to a wild abbreviation whereas
localtime_rz sets it to the more-sensible "MST".
> - offtime() is behind STD_INSPIRED, while localtime_rz() is behind
> NETBSD_INSPIRED, so it might not necessarily be available. FreeBSD
> for instance builds tzcode with STD_INSPIRED but not NETBSD_INSPIRED.
How about if we instead change FreeBSD to define NETBSD_INSPIRED? That
would help portability between FreeBSD and NetBSD, and would speed up
applications that deal with multiple timezones. As Eric S. Raymond
writes in
<http://www.catb.org/esr/time-programming/#_berkeley_multiple_timezone_api>,
"This is how it should have been done in the first place...".
More information about the tz
mailing list