On 23/12/2023 23:37, Max Nikulin wrote:
However being aware of tm_gmtoff GNU extension, I was not expected the following:(info "(libc) Broken-down Time") https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html#index-mktimeThe ‘mktime’ function ignores the specified contents of the ‘tm_wday’, ‘tm_yday’, ‘tm_gmtoff’, and ‘tm_zone’ members of the broken-down time structure. It uses the values of the other components to determine the calendar time; it’s permissible for these components to have unnormalized values outside their normal ranges. The last thing that ‘mktime’ does is adjust the components of the BROKENTIME structure, including the members that wereinitially ignored.
Actually I was confused by https://sourceware.org/pipermail/libc-alpha/2023-January/144860.htmlmktime version from IANA TZDB repository https://github.com/eggert/tz/ may take into account tm_gmtoff, but does it only to resolve ambiguity of local time close to backward time transition (DST or administrative one). If tm_gmtoff contains a value that is invalid for local time zone then this field is ignored.
GNU libc always ignores tm_gmtoff. Getting time_t from "struct tm" with arbitrary tm_gmtoff requires some code around mktime() call.