From @eb@meyer @end|ng |rom |@u@de  Fri Oct  2 09:48:03 2020
From: @eb@meyer @end|ng |rom |@u@de (Sebastian Meyer)
Date: Fri, 2 Oct 2020 09:48:03 +0200
Subject: [Rd] timezone tests and R-devel
In-Reply-To: <CAC2h7utR775fMZfFv50Zg9SC8fpoZq=sWcQyOEZKOhJnupabUA@mail.gmail.com>
References: <CAC2h7utR775fMZfFv50Zg9SC8fpoZq=sWcQyOEZKOhJnupabUA@mail.gmail.com>
Message-ID: <c60d5ff1-f0de-2129-d9f9-6dc6e7a80e62@fau.de>

Thank you for the report. In R-devel, all.equal.POSIXt() by default
reports inconsistent time zones. Previously,

> x <- Sys.time()
> all.equal(x, as.POSIXlt(x, tz = "EST5EDT"))

would return TRUE. To ignore the time zone attributes in R-devel, the
argument 'check.tzone = FALSE' needs to be used.

That said, I can reproduce the 'make check' failure in R-devel on Ubuntu
Linux when TZ is set, even if it is set to the system time zone:

$ export TZ=Europe/Berlin
$ make check
[...]
> running code in '../../tests/reg-tests-2.R' ... OK
>   comparing 'reg-tests-2.Rout' to '../../tests/reg-tests-2.Rout.save' ...7335c7335
> < [1] "'tzone' attributes are inconsistent ('' and 'Europe/Berlin')"
> ---
>> [1] TRUE


Compare the following two sessions:

> R-devel --vanilla --no-echo -e 'Sys.timezone(); x <- Sys.time(); all.equal(x, as.POSIXlt(x))'
[1] "Europe/Berlin"
[1] TRUE

> TZ='Europe/Berlin' R-devel --vanilla --no-echo -e 'Sys.timezone(); x <- Sys.time(); all.equal(x, as.POSIXlt(x))'
[1] "Europe/Berlin"
[1] "'tzone' attributes are inconsistent ('' and 'Europe/Berlin')"


So as.POSIXlt() sets a 'tzone' attribute if TZ is set, but this
behaviour is not new. Even with old R 3.6.3, I see

> R-3.6.3 --vanilla --slave -e 'attr(as.POSIXlt(Sys.time()), "tzone")'
[1] ""     "CET"  "CEST"

> TZ='Europe/Berlin' R-3.6.3 --vanilla --slave -e 'attr(as.POSIXlt(Sys.time()), "tzone")'
[1] "Europe/Berlin" "CET"           "CEST"

This might be system-specific.

I suggest to modify the test as attached for make check to pass in this
setting.

Best regards,

	Sebastian


Am 01.10.20 um 20:31 schrieb Kasper Daniel Hansen:
> The return value of Sys.time() today with a timezone of US/Eastern is
> unchanged between 4.0.3-patched and devel, but on devel the following test
> fails
>   all.equal(x, as.POSIXlt(x))
> with
>   x = Sys.time()
> 
> This means that devel does not complete make tests (failure on
> tests/reg-tests-2.R)
> 
> It is entirely possible that it is an error on my end, I use
>   export TZ="US/Eastern"
> but I have been using this for a while, and R-4.0.3-patched built today
> passes make tests.
> 
> Details below, and I am happy to provide more information.
> 
> Build platform: inside a conda environment on linux. I have been doing this
> for a while, but it is certainly a non-standard setup. GCC 7.3
> 
> Best,
> Kasper
> 
> On R version 4.0.3 beta (2020-10-01 r79286) I get
> 
>> x = Sys.time()
>> attributes(x)
> $class
> [1] "POSIXct" "POSIXt"
> 
>> attributes(as.POSIXlt(x))
> $names
>  [1] "sec"    "min"    "hour"   "mday"   "mon"    "year"   "wday"   "yday"
>  [9] "isdst"  "zone"   "gmtoff"
> 
> $class
> [1] "POSIXlt" "POSIXt"
> 
> $tzone
> [1] "US/Eastern" "EST"        "EDT"
> 
>> all.equal(x, as.POSIXlt(x))
> [1] TRUE
> 
> On R Under development (unstable) (2020-10-01 r79286) I get
>> x = Sys.time()
>> all.equal(x,x)
> [1] TRUE
>> attributes(as.POSIXlt(x))
> $names
>  [1] "sec"    "min"    "hour"   "mday"   "mon"    "year"   "wday"   "yday"
>  [9] "isdst"  "zone"   "gmtoff"
> 
> $class
> [1] "POSIXlt" "POSIXt"
> 
> $tzone
> [1] "US/Eastern" "EST"        "EDT"
> 
>> all.equal(x, as.POSIXlt(x))
> [1] "'tzone' attributes are inconsistent ('' and 'US/Eastern')"
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: all.equal.POSIXt-test.diff
Type: text/x-patch
Size: 910 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20201002/475d08fb/attachment.bin>


[Rd] timezone tests and R-devel
Sebastian Meyer