Skip to content
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

Datetime fxns #53

Merged
merged 9 commits into from
Dec 19, 2023
Merged

Datetime fxns #53

merged 9 commits into from
Dec 19, 2023

Conversation

wright13
Copy link
Collaborator

Added fxn to make ISO 8601 formatted strings have R-friendly UTC offsets. In theory it shouldn't do anything to strings with no UTC offset.
Also moved convert_datetime_format to this package and fixed one of the regular expressions that had been commented out. Added a regular expression to replace UTC offset indicators (e.g. -hh, -hhhh) with %z. We should talk about how to handle format strings with "Z" to indicate UTC+0000 before you accept this PR.

Wright added 2 commits November 17, 2023 09:32
Only works if fix_utc_offset is used when reading date/time strings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for slogging through date/times

Copy link
Member

@RobLBaker RobLBaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good!

#' fix_utc_offset(datetimes) # returns c("2023-11-16T03:32:49+0700", "2023-11-16T03:32:49-0700", "2023-11-16T03:32:49", "2023-11-16T03:32:49+0000") and warns about missing offset (see third element)
#'
fix_utc_offset <- function(datetime_strings) {
datetime_strings <- stringr::str_replace_all(datetime_strings, "[−‐‑‒–—―﹘﹣-]", "-") # replace every possible type of dash with a regular minus sign
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like non-ascii characters, likely in this line mucking up the package build.

fix_utc_offset <- function(datetime_strings) {
datetime_strings <- stringr::str_replace_all(datetime_strings, "[−‐‑‒–—―﹘﹣-]", "-") # replace every possible type of dash with a regular minus sign

datetime_strings <- stringr::str_replace_all(datetime_strings, "[\u2212\u2010\u2011\u2012\u2013\u2014\u2015\ufe58\ufe63\uff0d]", "-") # replace every possible type of dash with a regular minus sign
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, hopefully this does it!

@RobLBaker RobLBaker merged commit 7ab9f23 into master Dec 19, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants