Skip to content

Commit

Permalink
Improve performance of is_tz_present() by vectorizing regex
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Dec 6, 2024
1 parent af2cb77 commit 99abec0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/utils-date_time_parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ is_time_present <- function(input) {

is_tz_present <- function(input) {

any(
c(
grepl(get_tz_pattern_z(), input),
grepl(get_tz_pattern_hh(), input),
grepl(get_tz_pattern_hh_mm(), input),
grepl(get_tz_pattern_hhmm(), input)
)
regex <- paste0(
get_tz_pattern_z(),
get_tz_pattern_hh(),
get_tz_pattern_hh_mm(),
get_tz_pattern_hhmm(),
collapse = "|"
)
any(grepl(regex, input))
}

is_long_tzid_present <- function(input) {
Expand Down

0 comments on commit 99abec0

Please sign in to comment.