From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11145 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: DST change issue for timezones in southern hemisphere Date: Wed, 15 Mar 2017 20:41:00 -0400 Message-ID: <20170316004100.GK1693@brightrain.aerifal.cx> References: <34ea8f18-42d9-7817-7595-00435ac24b22@direct.lv> <20170315190112.GI1693@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1489624875 5321 195.159.176.226 (16 Mar 2017 00:41:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 16 Mar 2017 00:41:15 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11160-gllmg-musl=m.gmane.org@lists.openwall.com Thu Mar 16 01:41:12 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1coJTa-0000jd-4D for gllmg-musl@m.gmane.org; Thu, 16 Mar 2017 01:41:10 +0100 Original-Received: (qmail 28451 invoked by uid 550); 16 Mar 2017 00:41:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28429 invoked from network); 16 Mar 2017 00:41:12 -0000 Content-Disposition: inline In-Reply-To: <20170315190112.GI1693@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11145 Archived-At: On Wed, Mar 15, 2017 at 03:01:12PM -0400, Rich Felker wrote: > 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 > 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; > } Semantically this seems correct, so I'm applying it. Let me know if you still find the behavior incorrect. Thanks for reporting this. Rich