Closed bart1 closed 6 years ago
Not sure if it relates to #642 but here is the test code anyway
> Sys.timezone()
[1] "Europe/Zurich"
> Sys.getenv("TZ")
[1] ""
> lubridate:::C_local_tz()
[1] "raster465"
> as.POSIXct("2017-08-13", tz = "")
[1] "2017-08-13 CEST"
> ymd("2017-08-13", tz = "")
[1] "2017-08-13 02:00:00 CEST"
> force_tz(as.POSIXct("2017-08-13", tz = ""), "UTC")
[1] "2017-08-12 22:00:00 UTC"
>
> t1 <- as.POSIXct("2018-02-28 20:10:00")
> lubridate::minute(t1) <- 0
> t1
[1] "2018-02-28 21:00:00 CET"
> as.POSIXct("2017-07-01", format = "%Y-%m-%d") + days(1)
[1] "2017-06-02 02:00:00 CEST"
lubridate:::C_local_tz() [1] "raster465"
Ok. This is messed up :( I am surprised you are not seeing explicit TZ errors with this.
For now setting Sys.setenv(TZ="Europe/Zurich")
should fix this.
Would you mind checking the github version?
I just installed the devel version from github and it seems to work at least for the ceiling example
> Sys.timezone()
[1] "Europe/Zurich"
> Sys.getenv("TZ")
[1] ""
> lubridate:::C_local_tz()
[1] "Europe/Zurich"
> as.POSIXct("2017-08-13", tz = "")
[1] "2017-08-13 CEST"
> ymd("2017-08-13", tz = "")
[1] "2017-08-13 CEST"
> force_tz(as.POSIXct("2017-08-13", tz = ""), "UTC")
[1] "2017-08-13 UTC"
>
> t1 <- as.POSIXct("2018-02-28 20:10:00")
> lubridate::minute(t1) <- 0
> t1
[1] "2018-02-28 20:00:00 CET"
> as.POSIXct("2017-07-01", format = "%Y-%m-%d") + days(1)
[1] "2017-07-02 CEST"
>
> a<-structure(631166450, class = c("POSIXct", "POSIXt"), tzone = "")
> a
[1] "1990-01-01 05:00:50 CET"
> floor_date(a,'days');ceiling_date(a,'days')
[1] "1990-01-01 CET"
[1] "1990-01-02 CET"
>
> a<-structure(631166450, class = c("POSIXct", "POSIXt"), tzone = "CET")
> a
[1] "1990-01-01 05:00:50 CET"
> floor_date(a,'days');ceiling_date(a,'days')
[1] "1990-01-01 CET"
[1] "1990-01-02 CET"
>
> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] lubridate_1.7.2
loaded via a namespace (and not attached):
[1] httr_1.3.1 compiler_3.4.2 magrittr_1.5 R6_2.2.2 tools_3.4.2 withr_2.1.1 curl_3.1 yaml_2.1.16
[9] Rcpp_0.12.15 memoise_1.1.0 stringi_1.1.6 knitr_1.20 git2r_0.21.0 stringr_1.3.0 digest_0.6.15 devtools_1.13.5
Ok. Perfect. Will release asap. Thanks for the report!
I noticed some strange results where ceiling date sometimes does not produce a rounded date (see the example where the time becomes 1 am)