From: DJ Delorie <dj@redhat.com>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: libc-alpha@sourceware.org
Subject: Re: [swbz 29035] mktime vs non-DST
Date: Thu, 08 Sep 2022 16:25:57 -0400 [thread overview]
Message-ID: <xnczc53962.fsf@greed.delorie.com> (raw)
In-Reply-To: <e4757fd0-0eb5-067f-fed9-db21818c1a16@cs.ucla.edu>
> We have also seen a somewhat odd use of mktime() to detect DST transitions that
> DJ and I need to audit and verify against the changes you have implemented in
> gnulib.
FYI we've finished this, with no problems :-)
Paul Eggert <eggert@cs.ucla.edu> writes:
> From 674d4588995d24f8bc5167f73d8661ef5c82c2de Mon Sep 17 00:00:00 2001
> -# elif HAVE_TZSET
> +# else
Ok.
> From bfe919ce3bba22178429c5b39db98c26fd83272e Mon Sep 17 00:00:00 2001
> Heuristic: probe the adjacent timestamps in both directions,
> - looking for the desired isdst. This should work for all real
> - time zone histories in the tz database. */
> + looking for the desired isdst. If none is found within a
> + reasonable duration bound, assume a one-hour DST difference.
> + This should work for all real time zone histories in the tz
> + database. */
> +
> + /* +1 if we wanted standard time but got DST, -1 if the reverse. */
> + int dst_difference = (isdst == 0) - (tm.tm_isdst == 0);
Ok.
> - /* The longest period of DST in tzdata2003a is 536454000 seconds
> - (e.g., America/Jujuy starting 1946-10-01 01:00). The longest
> - period of non-DST is much longer, but it makes no real sense
> - to search for more than a year of non-DST, so use the DST
> - max. */
> - int duration_max = 536454000;
> + /* In TZDB 2021e, the longest period of DST (or of non-DST), in
> + which the DST (or adjacent DST) difference is not one hour,
> + is 457243209 seconds: e.g., America/Cambridge_Bay with leap
> + seconds, starting 1965-10-31 00:00 in a switch from
> + double-daylight time (-05) to standard time (-07), and
> + continuing to 1980-04-27 02:00 in a switch from standard time
> + (-07) to daylight time (-06). */
> + int duration_max = 457243209;
Ok.
> + /* No unusual DST offset was found nearby. Assume one-hour DST. */
> + t += 60 * 60 * dst_difference;
> + if (mktime_min <= t && t <= mktime_max && convert_time (convert, t, &tm))
> + goto offset_found;
> +
> __set_errno (EOVERFLOW);
> return -1;
> }
Ok.
LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>
prev parent reply other threads:[~2022-09-08 20:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-17 21:18 DJ Delorie
2022-08-17 21:50 ` Carlos O'Donell
2022-08-17 23:10 ` Paul Eggert
2022-08-18 1:39 ` DJ Delorie
2022-08-18 2:37 ` Carlos O'Donell
2022-08-18 3:16 ` Paul Eggert
2022-08-18 4:05 ` Carlos O'Donell
2022-08-18 21:17 ` DJ Delorie
2022-08-18 21:57 ` Paul Eggert
2022-08-18 22:40 ` DJ Delorie
2022-08-18 22:58 ` Paul Eggert
2022-08-19 18:15 ` DJ Delorie
2022-08-19 22:04 ` Paul Eggert
2022-08-18 3:02 ` Paul Eggert
2022-09-08 20:25 ` DJ Delorie [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=xnczc53962.fsf@greed.delorie.com \
--to=dj@redhat.com \
--cc=eggert@cs.ucla.edu \
--cc=libc-alpha@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).