Learn R Programming

chk (version 0.4.0)

chk_datetime: Check DateTime

Description

Checks if non-missing POSIXct scalar using

inherits(x, "POSIXct") && length(x) == 1L && !anyNA(x)

Usage

chk_datetime(x, x_name = NULL)

vld_datetime(x, x_name = NULL)

Arguments

x

The object to check.

x_name

A string of the name of object x or NULL.

Value

The chk_ function throws an informative error if the test fails.

The vld_ function returns a flag indicating whether the test was met.

Functions

  • vld_datetime: Validate DateTime

See Also

Other chk_scalars: chk_date(), chk_number(), chk_scalar(), chk_string(), chk_tz(), chk_whole_number()

Examples

Run this code
# NOT RUN {
# chk_datetime
chk_datetime(as.POSIXct("2001-01-02"))
try(chk_datetime(1))
# vld_datetime
vld_datetime(as.POSIXct("2001-01-02"))
vld_datetime(Sys.time())
vld_datetime(1)
vld_datetime("2001-01-02")
vld_datetime(c(Sys.time(), Sys.time()))
# }

Run the code above in your browser using DataLab