dates <-
c(
"2020-01-01",
"2020-02-11",
"2020-01-06",
"2020-0921",
"2020/10/30",
"2020-12-05",
"20231225"
)
# By inspecting the problematic dates it can be understood that
# the `.format` parameter needs to updated to include other variations.
iso8601_dttm <- create_iso8601(dates, .format = "y-m-d")
problems(iso8601_dttm)
# Including more parsing formats addresses the previous problems
formats <- c("y-m-d", "y-md", "y/m/d", "ymd")
iso8601_dttm2 <- create_iso8601(dates, .format = list(formats))
# So now `problems()` returns `NULL` because there are no more parsing issues.
problems(iso8601_dttm2)
# If you pass named arguments when calling `create_iso8601()` then they will
# be used to create the problems object.
iso8601_dttm3 <- create_iso8601(date = dates, .format = "y-m-d")
problems(iso8601_dttm3)
Run the code above in your browser using DataLab