year_month_day {clock} | R Documentation |
Calendar: year-month-day
Description
year_month_day()
constructs the most common calendar type using the
Gregorian year, month, day, and time of day components.
Usage
year_month_day(
year,
month = NULL,
day = NULL,
hour = NULL,
minute = NULL,
second = NULL,
subsecond = NULL,
...,
subsecond_precision = NULL
)
Arguments
year |
The year. Values |
month |
The month. Values |
day |
The day of the month. Values If |
hour |
The hour. Values |
minute |
The minute. Values |
second |
The second. Values |
subsecond |
The subsecond. If specified, If using milliseconds, values If using microseconds, values If using nanoseconds, values |
... |
These dots are for future extensions and must be empty. |
subsecond_precision |
The precision to interpret |
Details
Fields are recycled against each other using tidyverse recycling rules.
Fields are collected in order until the first NULL
field is located. No
fields after the first NULL
field are used.
Value
A year-month-day calendar vector.
Examples
# Just the year
x <- year_month_day(2019:2025)
# Year-month type
year_month_day(2020, 1:12)
# The most common use case involves year, month, and day fields
x <- year_month_day(2020, clock_months$january, 1:5)
x
# Precision can go all the way out to nanosecond
year_month_day(2019, 1, 2, 2, 40, 45, 200, subsecond_precision = "nanosecond")