Skip to content

bug adding days to POSIXct object in version 1.7.2 #643

@IanKopacka

Description

@IanKopacka

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions