From winstonchang1 at gmail.com  Thu Sep 15 21:15:31 2016
From: winstonchang1 at gmail.com (Winston Chang)
Date: Thu, 15 Sep 2016 14:15:31 -0500
Subject: [Rd] Time zone issues when compiling R
Message-ID: <CAFOpNVHzsFL2dTOic8_VULoc_xPwSqA=ZE5TX2wghxkrgc_iYA@mail.gmail.com>

I've been trying to build R 3.3.1 inside of a Nix environment on a
Ubuntu 16.04 machine. It builds, but then it fails a regression test
related to time zones, and I hope that someone could help me debug the
problem.

The failing test is in tests/reg-tests-rc.R
(https://github.com/wch/r-source/blob/c3fe9cd4/tests/reg-tests-1c.R#L1577-L1587):

## format.POSIXlt() of Jan.1 if  1941 or '42 is involved:
tJan1 <- function(n1, n2)
    strptime(paste0(n1:n2,"/01/01"), "%Y/%m/%d", tz="CET")
wDSTJan1 <- function(n1, n2)
    which("CEST" == sub(".* ", '', format(tJan1(n1,n2), usetz=TRUE)))
(w8 <- wDSTJan1(1801, 2300))
(w9 <- wDSTJan1(1901, 2300))
stopifnot(identical(w8, 141:142),# exactly 1941:1942 had CEST on Jan.1
          identical(w9,  41: 42))
## for R-devel Jan.2016 to Mar.14 -- *AND* for R 3.2.4 -- the above gave
## integer(0)  and  c(41:42, 99:100, ..., 389:390)  respectively


The resulting output is:
> (w8 <- wDSTJan1(1801, 2300))
integer(0)
> (w9 <- wDSTJan1(1901, 2300))
integer(0)
> stopifnot(identical(w8, 141:142),# exactly 1941:1942 had CEST on Jan.1
+           identical(w9,  41: 42))
Error: identical(w8, 141:142) is not TRUE
Execution halted


In this build of R, I get the following:
> strptime(paste0(1940:1945,"/01/01"), "%Y/%m/%d", tz="CET")
[1] "1940-01-01 CET" "1941-01-01 CET" "1942-01-01 CET" "1943-01-01 CET"
[5] "1944-01-01 CET" "1945-01-01 CET"


However, when I run the same code in R 3.3.1 installed via the .deb
packages on cran.r-project.org, I get a different result: years 1941
and 1942 have the CEST time zone. This is what the tests above were
expecting.
>  strptime(paste0(1940:1945,"/01/01"), "%Y/%m/%d", tz="CET")
[1] "1940-01-01 CET"  "1941-01-01 CEST" "1942-01-01 CEST" "1943-01-01 CET"
[5] "1944-01-01 CET"  "1945-01-01 CET"


I'm not sure where to start looking to fix this problem, and I'd
appreciate any pointers.


For reference, the test was introduced in:
  https://github.com/wch/r-source/commit/55cdf88dv

And that commit's message says that it fixed a bug introduced by:
    https://github.com/wch/r-source/commit/2e36b365

-Winston



[Rd] Time zone issues when compiling R
Winston Chang