On 01/26/2018 10:39 AM, Paul Eggert wrote:
J William Piggott wrote:
Rather than requiring applications to "call localtime and gmtime ... and subtract the results by hand", why couldn't the function(s) used by tzset for the tm_gmtoff value be made available for applications?
You don't need functions. All you need is tm_gmtoff; it's simple and easy to explain, and is a widely-used extension to POSIX.
You did not answer my question. Perhaps I didn't express it well. You just endorsed the diff(LOCALTIME, GMTIME) concept again in your update to the theory.html file. It is still being used in code that you maintain and code that I maintain. You advocate using tm_gmtoff as an alternate to diff(LOCALTIME, GMTIME), which implies that the algorithms that set tm_gmtoff are viable alternatives to diff(LOCALTIME, GMTIME). So my question is, why not get the offset directly from TZ/tzfile the same way tzset does for tm_gmtoff; instead of using the complex and imprecise math in diff(LOCALTIME, GMTIME)? Please don't be dismissive and say just use tm_gmtoff. The diff(LOCALTIME, GMTIME) concept is currently being used in parse_datetime.y, strftime_l.c, and so on. Plus you have endorsed it twice in as many days. I've already concluded that it could have been done using the tzset algorithms; I only wonder why it wasn't, and isn't now. If you are too busy to answer this question, that is fine, please don't.
Perhaps it should be documented in the glibc manual and elsewhere?
The glibc manual already documents tm_gmtoff, as do manuals for other operating systems that have it. Unfortunately tm_gmtoff is not standardized by C or POSIX, perhaps because standardizers mistakenly thought that strftime %z was enough.
I didn't suggest documenting tm_gmtoff. I suggested deprecating the vestigial API's and explaining their replacements. As you just did in the theory.html file. I find this very useful information, so thank you for taking time to document it. I think it would be wonderful if the same language could find its way into other documentation such as the glibc manual.