Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug adding days to POSIXct object in version 1.7.2 #643

Closed
IanKopacka opened this issue Feb 22, 2018 · 3 comments

Comments

@IanKopacka
Copy link

commented Feb 22, 2018

Using lubridate version 1.7.2 I have encountered the following behaviour when adding one day to a POSIXct object:

as.POSIXct("2017-07-01", format = "%Y-%m-%d") + days(1)
# [1] "2017-06-02 02:00:00 CEST"

The month is changed from july to june. This only happens when certain other packages are loaded (e.g. rgdal), and it doesn't happen every time you execute it (?):

library(lubridate)
library(rgdal)
as.POSIXct("2017-07-01", format = "%Y-%m-%d") + days(1)
as.POSIXct("2017-07-01", format = "%Y-%m-%d") + days(1)
# [1] "2017-07-02 CEST"
# [1] "2017-06-02 02:00:00 CEST"

It also doesn't happen with all dates, some dates seem to work fine (e.g. "2017-07-02")

as.POSIXct("2017-07-02", format = "%Y-%m-%d") + days(1)
# [1] "2017-07-03 02:00:00 CEST"

and seems to work when specifying a time zone:

as.POSIXct("2017-07-01", format = "%Y-%m-%d", tz = "CET") + days(1)
# [1] "2017-07-02 CEST"

Here is my session info:

R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rgdal_1.2-16    sp_1.2-7        lubridate_1.7.2 rj_2.1.0-13    

loaded via a namespace (and not attached):
[1] compiler_3.4.3  magrittr_1.5    tools_3.4.3     rj.gd_2.1.0-2  
[5] Rcpp_0.12.15    stringi_1.1.6   grid_3.4.3      stringr_1.2.0  
[9] lattice_0.20-35
@vspinu

This comment has been minimized.

Copy link
Member

commented Feb 22, 2018

This is a version of #642. Could you please move the discussion there. Thanks.

@vspinu

This comment has been minimized.

Copy link
Member

commented Feb 22, 2018

It should have been fixed in master. Could you please devtools::install_github("tidyverse/lubridate)" and confirm?

@IanKopacka

This comment has been minimized.

Copy link
Author

commented Feb 23, 2018

It works with the latest github version. Thanks!

@vspinu vspinu closed this Apr 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.