public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "eggert at cs dot ucla.edu" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug time/31144] mktime: returns clock for UTC with isdst=1 Date: Wed, 13 Dec 2023 17:52:21 +0000 [thread overview] Message-ID: <bug-31144-131-XWKZPjurFB@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-31144-131@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=31144 --- Comment #4 from eggert at cs dot ucla.edu --- (In reply to Florian Weimer from comment #3) > We already scan the entire tables while loading the time zone data, so we > could make a note if we have seen any DST hints, and if there are none > present, we could fail as before for tm_isdst > 0. We also don't know how > the tz project will model the introduction of DST if a zone changes > introduces DST for the first time, so the synthetic offset might well be > wrong. Yes, that could be done and shouldn't be hard to do. If so, we'd need to consult the trailing TZ string as well as the tm_isdst flags in the binary tables. However, failing would not be good, as we already learned when we put in code to have mktime fail. This is because a lot of code expects mktime to succeed unless the resulting time_t would be out of range. Better would be to ignore tm_isdst in timezones that have never observed tm_isdst. > We also don't know how the tz project will model the introduction of DST > if a zone changes introduces DST for the first time, > so the synthetic offset might well be wrong. There's no way in general to determine a synthetic offset. For example, America/St_Johns observed 1-hour DST in summer 1987 and 2-hour DST in summer 1988. If mktime is given a timestamp in January 1988 with tm_isdst=1 should it use a 1-hour offset or a 2-hour offset? That would depend on whether the timestamp was computed from in the previous summer but adding a few months, or from the next summer but subtracting a few months. Both scenarios are plausible. One possibility is that glibc mktime could use the incoming tm_gmtoff as a hint as to what synthetic offset to use. If the incoming tm_gmtoff is one of the DST offsets that appears in the TZif's binary data or TZ string, then mktime could use that offset. Although this would in theory rely on undefined behavior (tm_gmtoff might be uninitialized), in practice it would likely work better than what glibc does now. If this possibility were implemented lazily it shouldn't slow down the typical mktime case. -- You are receiving this mail because: You are on the CC list for the bug.
prev parent reply other threads:[~2023-12-13 17:52 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-12-12 5:46 [Bug time/31144] New: " aurelien at aurel32 dot net 2023-12-12 5:49 ` [Bug time/31144] " aurelien at aurel32 dot net 2023-12-12 9:40 ` schwab@linux-m68k.org 2023-12-12 23:37 ` eggert at cs dot ucla.edu 2023-12-13 10:11 ` fweimer at redhat dot com 2023-12-13 17:52 ` eggert at cs dot ucla.edu [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-31144-131-XWKZPjurFB@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).