new_date

0th

Percentile

Date, date-time, and duration S3 classes

  • A date (Date) is a double vector. Its value represent the number of days since the Unix "epoch", 1970-01-01. It has no attributes.

  • A datetime (POSIXct is a double vector. Its value represents the number of seconds since the Unix "Epoch", 1970-01-01. It has a single attribute: the timezone (tzone))

  • A duration (difftime)

Keywords
internal
Usage
new_date(x = double())

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

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

# S3 method for Date vec_type2(x, y)

# S3 method for POSIXt vec_type2(x, y)

# S3 method for difftime vec_type2(x, y)

# S3 method for Date vec_cast(x, to)

# S3 method for POSIXct vec_cast(x, to)

# S3 method for POSIXlt vec_cast(x, to)

# S3 method for difftime vec_cast(x, to)

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

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

# S3 method for 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.

Aliases
  • new_date
  • new_datetime
  • new_duration
  • vec_type2.Date
  • vec_type2.POSIXt
  • vec_type2.difftime
  • vec_cast.Date
  • vec_cast.POSIXct
  • vec_cast.POSIXlt
  • vec_cast.difftime
  • vec_arith.Date
  • vec_arith.POSIXct
  • vec_arith.difftime
Examples
# NOT RUN {
new_date(0)
new_datetime(0, tzone = "UTC")
new_duration(1, "hour")
# }
Documentation reproduced from package vctrs, version 0.1.0, License: GPL-3

Community examples

Looks like there are no examples yet.