
The tzcode distribution includes a (non-standard and undocumented) offtime() function but no offtime_r() function, which seems like an oversight. The attached patch (relative to 2023c) adds it. Regards, Dag-Erling

On 2023-04-20 02:53, Dag-Erling Smørgrav via tz wrote:
The tzcode distribution includes a (non-standard and undocumented) offtime() function but no offtime_r() function, which seems like an oversight.
The effect of offtime_r can be implemented by calling localtime_rz with a fixed-offset zone. As commentary says offtime "may well disappear in future releases of the time conversion package", it might be better for offtime to vanish than to multiply. For now I installed the attached patch to add more commentary about the situation.

Paul Eggert <eggert@cs.ucla.edu> writes:
The effect of offtime_r can be implemented by calling localtime_rz with a fixed-offset zone. As commentary says offtime "may well disappear in future releases of the time conversion package", it might be better for offtime to vanish than to multiply. For now I installed the attached patch to add more commentary about the situation.
I don't feel very strongly either way but I should point out that: - although the same effect can be achieved with localtime_rz(), it requires quite a bit of setup. - 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. I won't cry over offtime() if you decide to axe it but I think it's strange that there isn't an offtime_r() to go with it. DES -- Dag-Erling Smørgrav - des@des.no

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...".
participants (2)
-
Dag-Erling Smørgrav
-
Paul Eggert