[Rd] Fwd: [musl] strptime() question
albapompeo at gmail.com
Thu Feb 4 17:20:42 CET 2016
There is incompatibility between R strptime and musl libc. I posted
about it on their mailing list, but they need more information I can't
provide, so I'm forwarding the message here in hope R developers can
---------- Forwarded message ----------
From: Rich Felker <dalias at libc.org>
Date: Thu, Feb 4, 2016 at 2:07 PM
Subject: Re: [musl] strptime() question
To: Alba Pompeo <albapompeo at gmail.com>
Cc: musl at lists.openwall.com, Martin Maechler <maechler at stat.math.ethz.ch>
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 -
> 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
>  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)
>  0
> > t1 <- strptime("1970-01-01 00:00:00", "%Y-%m-%d %H:%M:%OS", tz="EST5EDT")
> > as.numeric(t1)
>  18000
> > 18000 / 3600
>  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
> 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.
More information about the R-devel