year_month_day: Calendar: year-month-day

Description Usage Arguments Details Value Examples

View source: R/gregorian-year-month-day.R

Description

year_month_day() constructs the most common calendar type using the Gregorian year, month, day, and time of day components.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
year_month_day(
  year,
  month = NULL,
  day = NULL,
  hour = NULL,
  minute = NULL,
  second = NULL,
  subsecond = NULL,
  ...,
  subsecond_precision = NULL
)

Arguments

year

[integer]

The year. Values [-32767, 32767] are generally allowed.

month

[integer / NULL]

The month. Values [1, 12] are allowed.

day

[integer / "last" / NULL]

The day of the month. Values [1, 31] are allowed.

If "last", then the last day of the month is returned.

hour

[integer / NULL]

The hour. Values [0, 23] are allowed.

minute

[integer / NULL]

The minute. Values [0, 59] are allowed.

second

[integer / NULL]

The second. Values [0, 59] are allowed.

subsecond

[integer / NULL]

The subsecond. If specified, subsecond_precision must also be specified to determine how to interpret the subsecond.

If using milliseconds, values [0, 999] are allowed.

If using microseconds, values [0, 999999] are allowed.

If using nanoseconds, values [0, 999999999] are allowed.

...

These dots are for future extensions and must be empty.

subsecond_precision

[character(1) / NULL]

The precision to interpret subsecond as. One of: "millisecond", "microsecond", or "nanosecond".

Details

Fields are recycled against each other.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 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")

clock documentation built on July 23, 2021, 1:06 a.m.