From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11143 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 15:01:12 -0400 Message-ID: <20170315190112.GI1693@brightrain.aerifal.cx> References: <34ea8f18-42d9-7817-7595-00435ac24b22@direct.lv> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="TRYliJ5NKNqkz5bu" X-Trace: blaine.gmane.org 1489604490 5633 195.159.176.226 (15 Mar 2017 19:01:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 15 Mar 2017 19:01:30 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11158-gllmg-musl=m.gmane.org@lists.openwall.com Wed Mar 15 20:01:21 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 1coEAi-0000aK-GL for gllmg-musl@m.gmane.org; Wed, 15 Mar 2017 20:01:20 +0100 Original-Received: (qmail 3086 invoked by uid 550); 15 Mar 2017 19:01:24 -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 2042 invoked from network); 15 Mar 2017 19:01:24 -0000 Content-Disposition: inline In-Reply-To: <34ea8f18-42d9-7817-7595-00435ac24b22@direct.lv> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11143 Archived-At: --TRYliJ5NKNqkz5bu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --TRYliJ5NKNqkz5bu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="southern-hemisphere.diff" 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; } --TRYliJ5NKNqkz5bu--