new_date: Date, date-time, and duration S3 classes

Description Usage Arguments Details Examples

View source: R/type-date-time.R

Description

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
new_date(x = double())

new_datetime(x = double(), tzone = "")

new_duration(x = double(), units = c("secs", "mins", "hours", "days", "weeks"))

## S3 method for class 'Date'
vec_ptype2(x, y, ...)

## S3 method for class 'POSIXt'
vec_ptype2(x, y, ...)

## S3 method for class 'difftime'
vec_ptype2(x, y, ...)

## S3 method for class 'Date'
vec_cast(x, to, ...)

## S3 method for class 'POSIXct'
vec_cast(x, to, ...)

## S3 method for class 'POSIXlt'
vec_cast(x, to, ...)

## S3 method for class 'difftime'
vec_cast(x, to, ...)

## S3 method for class 'Date'
vec_arith(op, x, y, ...)

## S3 method for class 'POSIXct'
vec_arith(op, x, y, ...)

## S3 method for class 'difftime'
vec_arith(op, x, y, ...)

Arguments

x

A double vector representing the number of days since UNIX epoch for new_date(), number of seconds since UNIX epoch for new_datetime(), and number of units for new_duration().

tzone

Time zone. A character vector of length 1. Either "" for the local time zone, or a value from OlsonNames()

units

Units of duration.

Details

These function help the base Date, POSIXct, and difftime classes fit into the vctrs type system by providing constructors, coercion functions, and casting functions.

Examples

1
2
3
new_date(0)
new_datetime(0, tzone = "UTC")
new_duration(1, "hour")

vctrs documentation built on Jan. 25, 2020, 1:06 a.m.