isValidDate: Test if object is a valid date

View source: R/isValidDate.R

isValidDateR Documentation

Test if object is a valid date

Description

Function to test if an object is a valid date.

Usage

isValidDate(dt)

Arguments

dt
  • the object to test

Details

if is.na(as.Date(dt)) does not throw an error and is TRUE, then the function returns TRUE; otherwise, it returns FALSE.

Based on discussion at https://gist.github.com/micstr/69a64fbd0f5635094a53.

Value

logical

Examples

isValidDate("2023-02-28");  #--expect TRUE

isValidDate("2023-02-30"); #--expect FALSE


wStockhausen/wtsUtilities documentation built on Feb. 3, 2025, 6:29 a.m.