Learn R Programming

popEpi (version 0.4.9)

is.Date: Test if object is a Date object

Description

Tests if an object is a Date object and returns a logical vector of length 1. IDate objects are also Date objects, but date objects from package date are not.

Usage

is.Date(obj)

Arguments

obj

object to test on

Value

`TRUE` if `obj` is of class `"Date"` or `"IDate"`.

See Also

get.yrs, is_leap_year, as.Date

Examples

Run this code
# NOT RUN {
## the base "capital Date" format
da <- as.Date("2000-01-01")
is.Date(da) ## TRUE
date::is.date(da) ## FALSE

## IDate format from data.table
library("data.table")
da <- as.IDate("2000-01-01")
is.Date(da) ## TRUE
date::is.date(da) ## FALSE

## from package "date"
da <- date::as.date("1jan2000")
is.Date(da) ## FALSE
date::is.date(da) ## TRUE
# }

Run the code above in your browser using DataLab