Learn R Programming

datetimeoffset (version 1.0.0)

weekdays.datetimeoffset: Additional datetime extractors

Description

Additional datetime extractors for datetimeoffset() objects.

Usage

# S3 method for datetimeoffset
weekdays(x, abbreviate = FALSE)

# S3 method for datetimeoffset months(x, abbreviate = FALSE)

# S3 method for datetimeoffset quarters(x, ...)

# S3 method for datetimeoffset julian(x, origin = as.Date("1970-01-01"), ...)

Value

weekdays(), months(), quarters(), julian() return character vectors. See base::weekdays() for more information.

Arguments

x

A datetimeoffset() datetime

abbreviate

Logical vector for whether the names should be abbreviated

...

Ignored

origin

Length one datetime of origin

Details

We implement datetimeoffset() support for the following S3 methods from base:

There is also datetimeoffset() support for the following methods from lubridate:

  • isoyear() and epiyear()

  • quarter() and semester()

  • week(), isoweek(), and epiweek()

  • wday() and wday<-()

  • qday() and qday<-()

  • yday() and yday<-()

  • am() and pm()

  • days_in_month()

  • dst()

  • leap_year()

Examples

Run this code
dto <- datetimeoffset_now()
print(dto)
weekdays(dto)
months(dto)
quarters(dto)
julian(dto)

if (require("lubridate")) {
  cat("`isoyear(dto)`: ", isoyear(dto), "\n")
  cat("`epiyear(dto)`: ", epiyear(dto), "\n")
  cat("`semester(dto)`: ", semester(dto), "\n")
  cat("`quarter(dto)`: ", quarter(dto), "\n")
  cat("`week(dto)`: ", week(dto), "\n")
  cat("`isoweek(dto)`: ", isoweek(dto), "\n")
  cat("`epiweek(dto)`: ", epiweek(dto), "\n")
  cat("`wday(dto)`: ", wday(dto), "\n")
  cat("`qday(dto)`: ", qday(dto), "\n")
  cat("`yday(dto)`: ", yday(dto), "\n")
  cat("`am(dto)`: ", am(dto), "\n")
  cat("`pm(dto)`: ", pm(dto), "\n")
  cat("`days_in_month(dto)`: ", days_in_month(dto), "\n")
  cat("`dst(dto)`: ", dst(dto), "\n")
  cat("`leap_year(dto)`: ", leap_year(dto), "\n")
}

Run the code above in your browser using DataLab