mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alba Pompeo <albapompeo@gmail.com>
To: musl@lists.openwall.com
Cc: Martin Maechler <maechler@stat.math.ethz.ch>
Subject: strptime() question
Date: Thu, 4 Feb 2016 13:27:40 -0200	[thread overview]
Message-ID: <CAJDAfTDpBrooMDDJ=p1xf5c_j6Rn9nAuAnBCvdotzUcgBkQRzA@mail.gmail.com> (raw)

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.

Ciao.


             reply	other threads:[~2016-02-04 15:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-04 15:27 Alba Pompeo [this message]
2016-02-04 16:07 ` Rich Felker
     [not found]   ` <CAJDAfTCENy0dyAYP5612OSMnNBc5U-AGjEoOgVgF1VisjDs8=g@mail.gmail.com>
     [not found]     ` <E98A2A10-27B5-48EF-988E-506F69E84BA6@r-project.org>
     [not found]       ` <CAJDAfTBwMx5eb5L+A2fbCpMB1ez-N+KdNViu69HkxAqfZs6RCg@mail.gmail.com>
2016-02-04 21:32         ` Fwd: [Rd] [musl] " Rich Felker
2016-02-06 12:35           ` Alba Pompeo
2016-02-06 22:55             ` 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='CAJDAfTDpBrooMDDJ=p1xf5c_j6Rn9nAuAnBCvdotzUcgBkQRzA@mail.gmail.com' \
    --to=albapompeo@gmail.com \
    --cc=maechler@stat.math.ethz.ch \
    --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).