From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: DST change issue for timezones in southern hemisphere
Date: Wed, 15 Mar 2017 15:01:12 -0400 [thread overview]
Message-ID: <20170315190112.GI1693@brightrain.aerifal.cx> (raw)
In-Reply-To: <34ea8f18-42d9-7817-7595-00435ac24b22@direct.lv>
[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]
On Mon, Mar 06, 2017 at 12:44:53PM +0200, JS wrote:
> Hi!
>
> For some reason DST change in southern hemisphere occurs 1 hour late
> when clock is turned backward and 1 hour early when clock is turned
> forward.
>
> For example, timezone for spec for Brazil is:
> BRT3BRST,M10.3.0/0,M2.3.0/0
> Which means that DST change occurs at midnight.
>
> Output of date for both DST changes:
>
> ~# date
> Sun Feb 19 00:59:59 BRST 2017
> ~# date
> Sun Feb 19 00:00:00 BRT 2017
>
> ~# date
> Sat Oct 14 22:59:59 BRT 2017
> ~# date
> Sun Oct 15 00:00:00 BRST 2017
>
> I've tested the same code on same hardware but with uClibc library
> instead of musl and it works fine.
I think this is indeed a bug. Can you confirm that the correct
progressions across DST change should be:
Sat Feb 18 23:59:59 BRST 2017
Sat Feb 18 23:00:00 BRT 2017
Sat Oct 14 23:59:59 BRT 2017
Sun Oct 15 01:00:00 BRST 2017
If so I think I have a working fix (see attached). The logic for
handling DST transition times for southern hemisphere was trying to do
something special that was actually wrong and didn't need to be
special-cased.
Rich
[-- Attachment #2: southern-hemisphere.diff --]
[-- Type: text/plain, Size: 617 bytes --]
diff --git a/src/time/__tz.c b/src/time/__tz.c
index 0e0c4ea..ffe8d40 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -373,18 +373,14 @@ void __secs_to_zone(long long t, int local, int *isdst, long *offset, long *oppo
long long t0 = rule_to_secs(r0, y);
long long t1 = rule_to_secs(r1, y);
+ if (!local) {
+ t0 += __timezone;
+ t1 += dst_off;
+ }
if (t0 < t1) {
- if (!local) {
- t0 += __timezone;
- t1 += dst_off;
- }
if (t >= t0 && t < t1) goto dst;
goto std;
} else {
- if (!local) {
- t1 += __timezone;
- t0 += dst_off;
- }
if (t >= t1 && t < t0) goto std;
goto dst;
}
next prev parent reply other threads:[~2017-03-15 19:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 10:44 JS
2017-03-15 19:01 ` Rich Felker [this message]
2017-03-16 0:41 ` Rich Felker
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=20170315190112.GI1693@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).