Description Usage Arguments Value Examples
View source: R/matchingTimeFormat.R
Find Time Format matching a Timestamp
1 2 3 4 5 6 7 | matchingTimeFormat(
timestamp,
timeFormats = getTimeFormats(),
method = 1L,
warn = TRUE,
failureValue = NULL
)
|
timestamp |
character timestamp to be checked against different possible timstamp formats |
timeFormats |
vector of possible time formats with placeholders
(year),
described for |
method |
passed to |
warn |
if |
failureValue |
value returned in case that no matching format was found.
Default: |
first time format in timeformats that matches the given timestamp. NULL is returned if none of the given timeformats matches.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Convert a character timestamp of which the format can be one of two
# possible formats into a POSIXct-object
possibleFormats <- c("%d.%m.%Y", "%d/%m/%Y")
x <- "14.01.2015"
t1 <- hsToPosix(x, format = matchingTimeFormat(x, possibleFormats))
# In fact this is what stringToPosix does (for only one timestamp)
t2 <- stringToPosix(x, formats = possibleFormats)
stopifnot(identical(t1, t2))
# You get a warning if none of the possible formats matches
matchingTimeFormat("01.14.2015", possibleFormats)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.