-
Notifications
You must be signed in to change notification settings - Fork 207
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
floor_date(x, unit = 'weeks') ignores lubridate.week.start option #509
Comments
ceiling_date also doesn't use the week.start option |
@pjrdata I have a quick hack of a solution here which you may find useful:
Example:
I haven't fully tested this, so my apologies if there's a mistake! |
Fixed. Thanks for reporting. |
Hi, I'm still seeing this issue with version 1.6.0 |
1.7.0 should be on CRAN within a day or two. |
After reading the documentation and many SO questions, I still couldn't really explain the difference between `round_date()` and `ceiling/floor_date` when using `unit="week"` and `week_start=1`. I thought it might just be that `round_date()` ignore `week_start=`, a bit like `floor/ceiling_date` back in the tidyverse#509 days. Without `week_start=`, everything looks as expected. ``` > date <- parse_date_time("November 27 2018 23:45", orders="bdyHM") > date [1] "2018-11-27 23:45:00 UTC" > lubridate::round_date(date, "week") [1] "2018-11-25 UTC" > lubridate::floor_date(date, "week") [1] "2018-11-25 UTC" > lubridate::ceiling_date(date, "week") [1] "2018-12-02 UTC" ``` But if you ask for weeks starting on Mondays (or any other day). Only `floor/ceiling_date` seem affected: ``` > lubridate::round_date(date, "week", week_start = 1) [1] "2018-11-25 UTC" > lubridate::floor_date(date, "week", week_start = 1) [1] "2018-11-26 UTC" > lubridate::ceiling_date(date, "week", week_start = 1) [1] "2018-12-03 UTC" ``` Apart from this tiny glitch, thanks for the awesome library: I don't want to use anything else when it comes to dates 👍 !
Hi it seems this issue has resurfaced. I'm using lubridate 1.7.4
Here's the session info in case there is any namespace issues.
Matrix products: default locale: attached base packages: other attached packages: loaded via a namespace (and not attached): |
Please use development. The OP was about floor_date, there was a bug in round_date as well. |
Hello,
floor_date(x, unit = 'weeks')
returns the same value (the previous Sunday, in my testing) regardless of what thelubridate.week.start
option is set to:As the above snippet shows, even though the results of
wday(x)
change according tolubridate.week.start
, the results offloor_date(x, unit = 'weeks')
do not. Intuitively, if the week start is set to Sunday, thenfloor_date()
should always return a Sunday; if the option is set to Monday, then the function should always return a Monday, and so on.I believe the issue is actually due to the
update()
function also ignoring this option:In the latter case,
wday(update(x, wday = 1))
does not give a result of1
, even though we explicitly setwday = 1
.The text was updated successfully, but these errors were encountered: