Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
ARROW-16394: [R] Implement lubridate's parsers with year, month and date components#13118
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
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
edfa6ed
added year, month, and day parsers + unit tests
dragosmg 4c5677d
lint
dragosmg 33463a6
skip tests on win & r 3.6
dragosmg 2172c0b
added comment about casting to `date32()` when `tz` is `NULL`
dragosmg 1d7fce9
added comment on why we need to handle a situation when `tz` is `NULL…
dragosmg 2f8bbd9
update comment
dragosmg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -518,6 +518,34 @@ register_bindings_datetime_parsers <- function() { | ||
| coalesce_output <- build_expr("coalesce", args = parse_attempt_expressions) | ||
| build_expr("assume_timezone", coalesce_output, options = list(timezone = tz)) | ||
| # we need this binding to be able to handle a NULL `tz`, which will then be | ||
| # used by bindings such as `ymd` to return, based on whether tz is NULL or | ||
| # not, a date or timestamp | ||
| if (!is.null(tz)) { | ||
| build_expr("assume_timezone", coalesce_output, options = list(timezone = tz)) | ||
| } else { | ||
| coalesce_output | ||
| } | ||
| }) | ||
| ymd_parser_vec <- c("ymd", "ydm", "mdy", "myd", "dmy", "dym") | ||
| ymd_parser_map_factory <- function(order) { | ||
| force(order) | ||
dragosmg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| function(x, tz = NULL) { | ||
| parse_x <- call_binding("parse_date_time", x, order, tz) | ||
| if (is.null(tz)) { | ||
| # we cast so we can mimic the behaviour of the `tz` argument in lubridate | ||
| # "If NULL (default), a Date object is returned. Otherwise a POSIXct with | ||
| # time zone attribute set to tz." | ||
| parse_x <- parse_x$cast(date32()) | ||
dragosmg marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| parse_x | ||
| } | ||
| } | ||
| for (ymd_order in ymd_parser_vec) { | ||
| register_binding(ymd_order, ymd_parser_map_factory(ymd_order)) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.