Skip to contents

Checks that start_date and end_date are a valid pair, coerces them to Date, and handles the case where both are NULL. When both are NULL and use_default_range = TRUE, a default range spanning from two years ago to one year ago is applied and reported to the user.

Usage

validate_dates(start_date, end_date, use_default_range = FALSE)

Arguments

start_date

A scalar coercible to Date via as.Date(), or NULL.

end_date

A scalar coercible to Date via as.Date(), or NULL.

use_default_range

A logical scalar. If TRUE and both date arguments are NULL, a default range spanning from two years ago to one year ago is used instead of returning NULL. Defaults to FALSE.

Value

A named list with elements start_date and end_date, both of class Date (or NULL when no dates are provided and use_default_range = FALSE).