Skip to contents

check format of dates from DeGAUSS container input file

Usage

check_dates(date, allow_missing = FALSE)

Arguments

date

vector of dates to be checked for formatting

allow_missing

logical. defaults to FALSE, resulting in an error if any dates are missing.

Value

reformatted vector of dates, or an error if dates could not be reformatted

Details

ISO formatted dates (i.e., "%Y-%m-%d" or YYYY-MM-DD) will stay the same U.S. standard slash formatted dates (common to Microsoft Excel; e.g., "%m/%d/%y" or MM/DD/YY, "%m/%d/%Y" or MM/DD/YYYY) will be reformatted to ISO format Any unrecognized input will cause an error and the user will be instructed to reformat their dates.

Examples

date <- c("1/1/21", "1/2/21", "1/3/21")
check_dates(date)
#> [1] "2021-01-01" "2021-01-02" "2021-01-03"