Commits


Danielle Navarro authored and GitHub committed b0734e68d6f
ARROW-14821: [R] Implement bindings for lubridate's floor_date, ceiling_date, and round_date (#12154) This patch provides dplyr bindings to for lubridate functions `floor_date()`, `ceiling_date()`, and `round_date()`. This is my first attempt at writing a patch, so my apologies if I've made any errors 🙂 ### Supported functionality: - Allows rounding to integer multiples of common time units (second, minutes, days, etc) - Mirrors the lubridate syntax allowing fractional units such as `unit = .001 seconds` as an alias for `unit = 1 millisecond` - Allows partial matching of date units based on first three characters: e.g. `sec`, `second`, `seconds` all match `second` - Mirrors lubridate in throwing errors when unit exceeds thresholds: 60 seconds, 60 minutes, 24 hours ~~### Major problems not yet addressed:~~ ~~- Does not yet support the `week_start` argument, and implicitly fixes `week_start = 4`~~ ~~- Does not yet mirror lubridate handling of timezones~~ ~~I'd prefer to fix these two issues before merging, but I'm uncertain how best to handle them. Any advice would be appreciated!~~ ~~### Minor things not yet addressed~~ ~~- During rounding lubridate sometimes coerces Date objects to POSIXct. This is not mirrored in the arrow bindings: date32 classes remain date32 classes. This introduces minor differences in rounding in some cases~~ ~~- Does not yet support the `change_on_boundary` argument to `ceiling_date()`. It's a small discrepancy, but it means that the default behaviour of the arrow dplyr binding mirrors lubridate prior to v1.6.0~~ EDIT: issues now addressed! Authored-by: Danielle Navarro <djnavarro@protonmail.com> Signed-off-by: Neal Richardson <neal.p.richardson@gmail.com>