validate icon indicating copy to clipboard operation
validate copied to clipboard

Add convenience function to check if a field can be interpreted as date.

Open markvanderloo opened this issue 3 years ago • 1 comments

e.g. YYYYMMDD (as integer) or ISO8601 formats.

markvanderloo avatar Feb 11 '21 13:02 markvanderloo

I'm also interested in this!

Unfortunately I'm unaware of any simple, readable way to implement this in R.

A function like this might be suitable?

date_format <- function(x) {
  return(
    # YYYY-MM-DD
    # https://en.wikipedia.org/wiki/ISO_8601#Dates
    # YYYY = Four digits
    # MM = a zero-padded number 01-12
    # DD = a zero padded number 00-31
    grepl("^\\d{4}-([0]\\d|1[0-2])-([0-2]\\d|3[01])$", x)
  )
}

Joe-Heffer-Shef avatar Oct 25 '23 13:10 Joe-Heffer-Shef