year-month-day-narrow: Narrow: year-month-day

year-month-day-narrowR Documentation

Narrow: year-month-day

Description

This is a year-month-day method for the calendar_narrow() generic. It narrows a year-month-day vector to the specified precision.

Usage

## S3 method for class 'clock_year_month_day'
calendar_narrow(x, precision)

Arguments

x

⁠[clock_year_month_day]⁠

A year-month-day vector.

precision

⁠[character(1)]⁠

One of:

  • "year"

  • "month"

  • "day"

  • "hour"

  • "minute"

  • "second"

  • "millisecond"

  • "microsecond"

  • "nanosecond"

Value

x narrowed to the supplied precision.

Examples

# Hour precision
x <- year_month_day(2019, 1, 3, 4)
x

# Narrowed to day precision
calendar_narrow(x, "day")

# Or month precision
calendar_narrow(x, "month")

# Subsecond precision can be narrowed to second precision
milli <- calendar_widen(x, "millisecond")
micro <- calendar_widen(x, "microsecond")
milli
micro

calendar_narrow(milli, "second")
calendar_narrow(micro, "second")

# But once you have "locked in" a subsecond precision, it can't be
# narrowed to another subsecond precision
try(calendar_narrow(micro, "millisecond"))

clock documentation built on Sept. 11, 2024, 8:39 p.m.