Skip to contents

Getter methods for datetimeoffset() objects.

Usage

# S3 method for class 'datetimeoffset'
get_year(x)

# S3 method for class 'datetimeoffset'
get_month(x)

# S3 method for class 'datetimeoffset'
get_day(x)

# S3 method for class 'datetimeoffset'
get_hour(x)

# S3 method for class 'datetimeoffset'
get_minute(x)

# S3 method for class 'datetimeoffset'
get_second(x)

# S3 method for class 'datetimeoffset'
get_nanosecond(x)

get_subsecond_digits(x)

# S3 method for class 'datetimeoffset'
get_subsecond_digits(x)

# Default S3 method
get_subsecond_digits(x)

get_hour_offset(x)

# S3 method for class 'datetimeoffset'
get_hour_offset(x)

# Default S3 method
get_hour_offset(x)

# S3 method for class 'POSIXt'
get_hour_offset(x)

get_minute_offset(x)

# S3 method for class 'datetimeoffset'
get_minute_offset(x)

# Default S3 method
get_minute_offset(x)

# S3 method for class 'POSIXt'
get_minute_offset(x)

get_tz(x)

# S3 method for class 'datetimeoffset'
get_tz(x)

# S3 method for class 'Date'
get_tz(x)

# S3 method for class 'POSIXt'
get_tz(x)

# S3 method for class 'clock_zoned_time'
get_tz(x)

# Default S3 method
get_tz(x)

Arguments

x

A datetime object.

Value

The component

Details

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

We also implemented new S3 getter methods:

  • get_subsecond_digits()

  • get_hour_offset()

  • get_minute_offset()

  • get_tz()

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

Examples

library("clock")
if ("Europe/Paris" %in% OlsonNames()) {
  dt <- as_datetimeoffset("1918-11-11T11:11:11.1234+00:00[Europe/Paris]")
} else {
  dt <- as_datetimeoffset("1918-11-11T11:11:11.1234")
}
get_year(dt)
#> [1] 1918
get_month(dt)
#> [1] 11
get_day(dt)
#> [1] 11
get_hour(dt)
#> [1] 11
get_minute(dt)
#> [1] 11
get_second(dt)
#> [1] 11
get_nanosecond(dt)
#> [1] 123400000
get_subsecond_digits(dt)
#> [1] 4
get_hour_offset(dt)
#> [1] 0
get_minute_offset(dt)
#> [1] 0
get_tz(dt)
#> [1] "Europe/Paris"
if (require("lubridate")) {
  paste0(year(dt), "-", month(dt), "-", day(dt),
         "T", hour(dt), ":", minute(dt), ":", second(dt),
         "[", tz(dt), "]")
}
#> Loading required package: lubridate
#> 
#> Attaching package: ‘lubridate’
#> The following object is masked from ‘package:clock’:
#> 
#>     as_date
#> The following objects are masked from ‘package:base’:
#> 
#>     date, intersect, setdiff, union
#> [1] "1918-11-11T11:11:11[Europe/Paris]"