check_valid_date: Check date for validity

Description Usage Arguments Value Examples

View source: R/check_valid_date.R

Description

Check date for validity

Usage

1
check_valid_date(.year = NULL, .month = NULL, .day = NULL)

Arguments

.year

Integer value.

.month

Integer value.

.day

Integer value.

Value

Returns NULL if date is ok, else a string with the error message.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# errors
check_valid_date(.year = NA)

date.future <- Sys.Date() + 1L
check_valid_date(.year = lubridate::year(date.future),
                 .month = lubridate::month(date.future),
                 .day = lubridate::day(date.future))

check_valid_date(.year = lubridate::year(date.future) + 1L)
check_valid_date(.year = lubridate::year(date.future),
                 .month = lubridate::month(date.future) + 1L)

check_valid_date(.year = 2016, .month = NA, .day = 10)
check_valid_date(.year = 2018, .month = 13)
check_valid_date(.year = 2018, .month = 12, .day = 32)

# ok
check_valid_date(.year = 2019, .month = 1, .day = 10)
check_valid_date(.year = 2019, .month = 10, .day = NA)
check_valid_date(.year = 2019, .month = NA, .day = NA)

markusdumke/lepidisthelper documentation built on Oct. 21, 2019, 3:54 a.m.