Test if object is a Date object

Share:

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

1
is.Date(obj)

Arguments

obj

object to test on

Author(s)

Joonas Miettinen

See Also

get.yrs, is_leap_year, as.Date

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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
 

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.