Learn R Programming

assertive (version 0.2-6)

assert_all_are_date_strings: Does the character vector contain dates?

Description

Checks that the input contains dates or times.

Usage

assert_all_are_date_strings(x, format = "%F %T")

assert_any_are_date_strings(x, format = "%F %T")

is_date_string(x, format = "%F %T", .xname = get_name_in_parent(x))

Arguments

x
Input to check.
format
Expected format of the dates. See strptime.
.xname
Not intended to be called directly.

Value

  • A logical vector that is TRUE when the input contains valid dates or times.

See Also

strptime for specifying formats, and the lubridate package for automatic guessing of date formats (and other date manipulation functions).

Examples

Run this code
x <- c("9999-12-31 23:59:59", "wednesday", NA)
is_date_string(x)
assert_all_are_date_strings("01Aug1979", format = "%d%b%Y") #My DOB!

Run the code above in your browser using DataLab