grattan (version 2024.1.1)

validate_date: 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")

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.

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.

Examples

Run this code

validate_date("2020-01-01")

Run the code above in your browser using DataLab