is_date: Is the input a date?

Description Usage Arguments Value Examples

View source: R/is-date.R

Description

Checks to see if the input is a Date or POSIXt object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
assert_is_date(x, severity = getOption("assertive.severity", "stop"))

assert_is_posixct(x, severity = getOption("assertive.severity", "stop"))

assert_is_posixlt(x, severity = getOption("assertive.severity", "stop"))

is_date(x, .xname = get_name_in_parent(x))

is_posixct(x, .xname = get_name_in_parent(x))

is_posixlt(x, .xname = get_name_in_parent(x))

Arguments

x

Input to check.

severity

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

.xname

Not intended to be used directly.

Value

The is_* functions return TRUE or FALSE depending upon whether or not the input is a datetime object.

The assert_* functions return nothing but throw an error if the corresponding is_* function returns FALSE.

Examples

1
2
3
4
5
is_date(Sys.Date())
is_posixct(Sys.time())

# These examples should fail.
assertive.base::dont_stop(assert_is_date(Sys.time()))

assertive.types documentation built on May 1, 2019, 10:31 p.m.