Checks if timestamps are formatted according to timeformat

hasTimeFormat(timestamps, timeformat = NULL, method = 1L)

Arguments

timestamps

character strings representing timestamps.

timeformat

character string giving a date-time format as used by strptime.

method

Method used to do the check. 1: Check based on pattern matching 2: Check whether as.POSIXct returns valid time objects and if re-formatting these objects are identical to the original timestamps. The simple check should be much faster for many timestamps to be checked.

Examples

hasTimeFormat("1.1.2012", "%d.%m.%Y") # TRUE
#> [1] TRUE
hasTimeFormat("1.13.2012", "%d.%m.%Y") # FALSE
#> [1] FALSE
hasTimeFormat("1/31/2012", "%m/%d/%Y") # TRUE
#> [1] TRUE
hasTimeFormat("31/1/2012", "%m/%d/%Y") # FALSE
#> [1] FALSE
hasTimeFormat(c("1.1.", "1.13.", "12.12.", "32.1."), "%d.%m.")
#> [1] TRUE FALSE TRUE FALSE
# TRUE FALSE TRUE FALSE