validate_date {grattan}R Documentation

Verifying validity of dates

Description

Many functions expect Dates. Determining that they are validly entered is often quite computationally costly, relative to the core calculations. These internal functions provide mechanisms to check validity quickly, while still providing clear, accurate error messages.

Usage

validate_date(date_to_verify, from = NULL, to = NULL, deparsed = "Date")

Arguments

date_to_verify

(character) A user-provided value, purporting to be character vector of dates.

from, to

Indicating the range of years valid for date_to_verify. Default set to -Inf and Inf respectively (i.e. there is no bound)

deparsed

The name of variable to appear in error messages.

Value

date_to_verify as a Date object, provided it can be converted to a Date and all elements are within the bounds from and to.

Examples


validate_date("2020-01-01")


[Package grattan version 2024.1.1 Index]