All dint objects can be coerced to base R Date or Datetime (POSIXct) types. The resulting date will always default to the first possible Date/Datetime in this period.

# S3 method for date_xx
as.POSIXlt(x, tz = "", ...)

# S3 method for date_xx
as.POSIXct(x, tz = "", ...)

Sys.date_yq()

Sys.date_ym()

Sys.date_yw()

# S3 method for date_y
as.Date(x, ...)

# S3 method for date_ym
as.Date(x, ...)

# S3 method for date_yq
as.Date(x, ...)

# S3 method for date_yw
as.Date(x, ...)

Arguments

x

any R object

tz

time zone specification to be used for the conversion, if one is required. System-specific (see time zones), but "" is the current time zone, and "GMT" is UTC (Universal Time, Coordinated). Invalid values are most commonly treated as UTC, on some platforms with a warning.

...

passed on to methods

Value

An Object of the appropriate base R type (Date, POSIXct, or POSIXlt)

Details

If lubridate is loaded, methods for lubridate generics (such as lubridate::month() and lubridate::year()) are also made available by dint.

Examples

as.Date(date_yq(2017, 2))
#> [1] "2017-04-01"
#> [1] "2017-04-01 UTC"
# When coercing to datetime, the default timezone is UTC as.POSIXct(date_yq(2017, 2))
#> [1] "2017-04-01 UTC"