Learn R Programming

clock (version 0.7.1)

iso-year-week-day-arithmetic: Arithmetic: iso-year-week-day

Description

These are iso-year-week-day methods for the arithmetic generics.

  • add_years()

You cannot add weeks or days to an iso-year-week-day calendar. Adding days is much more efficiently done by converting to a time point first by using as_naive_time() or as_sys_time(). Adding weeks is equally as efficient as adding 7 days. Additionally, adding weeks to an invalid iso-year-week object containing iso_year_week_day(2019, 53) would be undefined, as the 53rd ISO week of 2019 doesn't exist to begin with.

Usage

# S3 method for clock_iso_year_week_day
add_years(x, n, ...)

Value

x after performing the arithmetic.

Arguments

x

[clock_iso_year_week_day]

A iso-year-week-day vector.

n

[integer / clock_duration]

An integer vector to be converted to a duration, or a duration corresponding to the arithmetic function being used. This corresponds to the number of duration units to add. n may be negative to subtract units of duration.

...

These dots are for future extensions and must be empty.

Details

x and n are recycled against each other using tidyverse recycling rules.

Examples

Run this code
x <- iso_year_week_day(2019, 1, 1)
add_years(x, 1:2)

Run the code above in your browser using DataLab