public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bugdal at aerifal dot cx" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug time/31558] mktime wildly mishandles times near Pacific/Apia tz discontinuity
Date: Tue, 02 Apr 2024 13:07:05 +0000	[thread overview]
Message-ID: <bug-31558-131-mKcBumGkK2@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31558-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=31558

Rich Felker <bugdal at aerifal dot cx> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|NOTABUG                     |---
             Status|RESOLVED                    |UNCONFIRMED

--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> ---
> I don't see a bug here. The input to mktime is ambiguous, since two periods of standard time are plausible, either the one at -11 (e.g, from 2011-04-02 to 201-09-24) or the one at +13 (e.g., from 2012-04-02 to 2012-09-30).

This is NOT THE CASE. The input time is an unambiguous time *outside* of the
zone transition cut. The nonexistent (thus ambiguous) range is 2011-12-30
00:00:00 to 2011-12-30 23:59:59. The requested time is 2011-12-31 01:00:00, but
specified as "the time that would have been 00:00:00 if DST were not active".

Note that, even if it were handled as being in DST, this would *still* be
outside of the zone transition cut, so the bug shouldn't be a matter of
crossing the cut as an intermediate calculation. It's probably glibc using the
adjacent rule across the cut, rather than the adjacent opposite-DST-state rule
in spring, to adjust for tm_isdst not matching the DST state in effect at the
requested time.

> The right thing to do is to set tm_isdst to -1 if you don't know the actual value.

Setting tm_isdst=-1 is semantically completely different from setting
tm_isdst=0. tm_isdst=0 does not mean "we don't know if it's DST or not". It
means "we are asking mktime to normalize a time specified in terms of whether
it's given in DST or not, to the actual state of DST at that time". It would
arise in situations like requesting "now - 93 days" on April 2.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-04-02 13:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-25 20:42 [Bug time/31558] New: " bugdal at aerifal dot cx
2024-03-27 16:49 ` [Bug time/31558] " schwab@linux-m68k.org
2024-03-27 17:00 ` bugdal at aerifal dot cx
2024-03-27 18:23 ` schwab@linux-m68k.org
2024-03-28 12:48 ` schwab@linux-m68k.org
2024-03-28 21:01 ` eggert at cs dot ucla.edu
2024-04-02 11:08 ` schwab@linux-m68k.org
2024-04-02 13:07 ` bugdal at aerifal dot cx [this message]
2024-04-02 16:42 ` eggert at cs dot ucla.edu
2024-04-02 17:07 ` bugdal at aerifal dot cx
2024-04-02 18:52 ` eggert at cs dot ucla.edu

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-31558-131-mKcBumGkK2@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: link
Be 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).