From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/9261 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: strptime() question Date: Thu, 4 Feb 2016 11:07:08 -0500 Message-ID: <20160204160708.GP9349@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1454602051 4782 80.91.229.3 (4 Feb 2016 16:07:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Feb 2016 16:07:31 +0000 (UTC) Cc: musl@lists.openwall.com, Martin Maechler To: Alba Pompeo Original-X-From: musl-return-9274-gllmg-musl=m.gmane.org@lists.openwall.com Thu Feb 04 17:07:30 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1aRMRN-0004mg-O7 for gllmg-musl@m.gmane.org; Thu, 04 Feb 2016 17:07:30 +0100 Original-Received: (qmail 26339 invoked by uid 550); 4 Feb 2016 16:07:26 -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 26318 invoked from network); 4 Feb 2016 16:07:25 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:9261 Archived-At: On Thu, Feb 04, 2016 at 01:27:40PM -0200, Alba Pompeo wrote: > Hello musl. > > I've built R on a musl system and "make check-all" fails because R > does not get correct timezone information from the system. > > Here's the error - > http://pastebin.com/raw/32D3ngNZ > > This would be correct, > > > difftime( > + as.POSIXct(c("1970-01-01 00:00:00", "1970-01-01 12:00:00"), tz="EST5EDT"), > + as.POSIXct(c("1970-01-01 00:00:00", "1970-01-01 00:00:00"), tz="UTC")) > Time differences in hours > [1] 5 17 > > but my system gives 4 16 which would suggest that it thinks that > there is only 4 hours time difference between UTC and EST5EDT and > that is just wrong. > > The above can be translated to this (slightly more low-level) R code which > is already somewhat close to the internal C code of R : > > > t0 <- strptime("1970-01-01 00:00:00", "%Y-%m-%d %H:%M:%OS", tz="UTC") > > as.numeric(t0) > [1] 0 > > > t1 <- strptime("1970-01-01 00:00:00", "%Y-%m-%d %H:%M:%OS", tz="EST5EDT") > > as.numeric(t1) > [1] 18000 > > 18000 / 3600 > [1] 5 > > > > That's why its 5 hours. > R's strptime() is close to the C library strptime(), so think musl > specialists should have it easy to do the above from C and find out > why you get 4 hour instead of 5 hour difference. > > I'm certain this isn't a problem with R and I think it's up to me to > ensure that your system's C library strptime() function returns the > correct numbers for the above example, but I can't understand why it > doesn't. > > Can anyone help here? > Thanks a lot. I think we need to understand how R's strptime function implements its tz argument, since this is not part of the POSIX strptime API. It's possible that there's a bug in musl here, but it seems equally possible that R is doing some dubious hacks with switching timezones. I'm also wondering what you're expecting from the timezone name EST5EDT, which is not generally usable; it's in POSIX TZ form rather than zoneinfo, but it lacks any information about when the switch to daylight time happens, and the defaults are not correct with respect to modern policy. Rich