Skip to contents

Tests if an object inherits from some/all of R's date types: Date, POSIXt, POSIXct and POSIXlt.

Usage

is.datetype(x)

is.Date(x)

is.POSIXt(x)

is.POSIXct(x)

is.POSIXlt(x)

Arguments

x

an R object.

Value

TRUE or FALSE.

Details

is.datetype checks if the object inherits from either Date or POSIXt.

is.Date checks if the object inherits from Date.

is.POSIXt checks if the object inherits from POSIXt.

is.POSIXct checks if the object inherits from POSIXct.

is.POSIXlt checks if the object inherits from POSIXlt.

Examples

a <- "2020-01-01"
b <- as.Date("2020-01-01")
c <- 123

is.Date(a)
#> [1] FALSE
is.Date(b)
#> [1] TRUE
is.Date(c)
#> [1] FALSE

is.Date(as.POSIXct(123))
#> [1] FALSE
is.Date(as.POSIXlt(123))
#> [1] FALSE

is.datetype(as.POSIXct(123))
#> [1] TRUE
is.datetype(as.POSIXlt(123))
#> [1] TRUE