From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 06D77385DC38; Wed, 13 Dec 2023 17:52:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06D77385DC38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1702489942; bh=mREB+428KBU1NTfKMDcQB5HX6jgsL7TsiUL/9/rAVz0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WyTz3QUMdDH/VTQ/i+in6GikK4lMYfyV0Rg9yICGfRdn77Ba5syIlW0hItWrAj83a io73dYYxEXnGJ1vZ519oHVaFbrkSCnm4mxM4dW6MpoFGxzAgjf/rNdOexUMbnJLhEr YEuvH50YB2NFb39jkFwgcDlJQZAUr3R4rbIanNR8= From: "eggert at cs dot ucla.edu" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: time X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: NOTABUG X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31144 --- 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 co= de 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=3D1 shou= ld 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 co= uld 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. --=20 You are receiving this mail because: You are on the CC list for the bug.=