weekdays.datetimeoffset: Additional datetime extractors

View source: R/extractors.r

weekdays.datetimeoffsetR Documentation

Additional datetime extractors

Description

Additional datetime extractors for datetimeoffset() objects.

Usage

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

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

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

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

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:

  • weekdays()

  • months()

  • quarters()

  • julian()

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()

Value

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

Examples

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")
}


datetimeoffset documentation built on April 4, 2025, 4:42 a.m.