Simple enough question but cannot find an answer. If I have some dummy timestamp:
foo <- strftime(Sys.time(), "%Y-%m-%dT%H:%M:%SZ")
With format:
"%Y-%m-%dT%H:%M:%SZ".
How would I check what format foo is? I need to check that a user has submitted a timestamp in the correct format and would therefore need something like
if (func_bar(foo) != "%Y-%m-%dT%H:%M:%SZ") {stop("Complain")}
Is there a intrinsic R function for this?
UPDATE: (For clarity) I understand that I could change the format automatically for the user, i.e just convert which ever date is submitted. But in this particular case I want to catch it. For example I could use:
foo1 <- as.POSIXlt(Sys.time(), "UTC", "%Y-%m-%dT%H:%M:%S")
foo <- strftime(foo1, "%Y-%m-%dT%H:%M:%SZ")
To get it into the correct format.