assert_all_are_date_strings {assertive.datetimes}R Documentation

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",
  na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop")
)

assert_any_are_date_strings(
  x,
  format = "%F %T",
  na_ignore = FALSE,
  severity = getOption("assertive.severity", "stop")
)

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.

na_ignore

A logical value. If FALSE, NA values cause an error; otherwise they do not. Like na.rm in many stats package functions, except that the position of the failing values does not change.

severity

How severe should the consequences of the assertion be? Either "stop", "warning", "message", or "none".

.xname

Not intended to be used 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

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!

[Package assertive.datetimes version 0.0-3 Index]