Skip to content

These are year-month-day methods for the getter generics.

  • get_year() returns the Gregorian year.

  • get_month() returns the month of the year.

  • get_day() returns the day of the month.

  • There are sub-daily getters for extracting more precise components.

Usage

# S3 method for clock_year_month_day
get_year(x)

# S3 method for clock_year_month_day
get_month(x)

# S3 method for clock_year_month_day
get_day(x)

# S3 method for clock_year_month_day
get_hour(x)

# S3 method for clock_year_month_day
get_minute(x)

# S3 method for clock_year_month_day
get_second(x)

# S3 method for clock_year_month_day
get_millisecond(x)

# S3 method for clock_year_month_day
get_microsecond(x)

# S3 method for clock_year_month_day
get_nanosecond(x)

Arguments

x

[clock_year_month_day]

A year-month-day to get the component from.

Value

The component.

Examples

x <- year_month_day(2019, 1:3, 5:7, 1, 20, 30)

get_month(x)
#> [1] 1 2 3
get_day(x)
#> [1] 5 6 7
get_second(x)
#> [1] 30 30 30

# Cannot extract more precise components
y <- year_month_day(2019, 1)
try(get_day(y))
#> Error in calendar_require_minimum_precision(x, PRECISION_DAY, "get_day") : 
#>   `get_day()` requires a minimum precision of 'day'.

# Cannot extract components that don't exist for this calendar
try(get_quarter(x))
#> Error in stop_clock(message, "clock_error_unsupported_calendar_op") : 
#>   This calendar doesn't support `get_quarter()`.