asDatePOSIXct: Conversion from POSIXct to Date

Description Usage Arguments Details Value Author(s) Examples

Description

Conversion from POSIXct to Date

Usage

1
asDatePOSIXct(x, tz = "")

Arguments

x

A POSIXct vector

tz

An optional timezone string

Details

This function provides a direct conversion from POSIXct to Date. As of R-3.5.1, conversion from POSIXct to Date creates an intermediate POSIXlt object. This intermediate POSIXlt object uses a non-trivial amount of memory. The direct conversion is more memory efficient, and therefore approximately twice as fast as the current solution in base R.

Value

A vector of Date objects

Author(s)

Joshua Ulrich

Examples

1
2
3
4
p <- .POSIXct(1540181413, "America/Chicago")
as.Date(p)                     # Using UTC timezone
as.Date(p, "America/Chicago")  # Using local timezone
asDatePOSIXct(p)               # Direct, using local timezone

RApiDatetime documentation built on May 2, 2019, 4:16 a.m.