Skip to content

floor_date(date, "year") is off by one in leap years #567

@nacnudus

Description

@nacnudus
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:base':
#> 
#>     date
floor_date(ymd("2016-02-29"), "year")
#> [1] "2016-01-01"
floor_date(ymd("2016-03-01"), "year")
#> [1] "2015-12-31"

# I would expect the equivalent of this
ymd("2016-02-29") - ddays(yday(ymd("2016-02-29")) - 1)
#> [1] "2016-01-01"
ymd("2016-03-31") - ddays(yday(ymd("2016-03-31")) - 1)
#> [1] "2016-01-01"

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