These are year-day methods for the arithmetic generics.

Notably, *you cannot add days to a year-day*. For day-based arithmetic,
first convert to a time point with `as_naive_time()`

or `as_sys_time()`

.

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

x |
A year-day vector. |
---|---|

n |
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. |

... | These dots are for future extensions and must be empty. |

`x`

after performing the arithmetic.

`x`

and `n`

are recycled against each other.

#> <year_day<day>[5]> #> [1] "2020-010" "2021-010" "2022-010" "2023-010" "2024-010"#> <year_day<day>[1]> #> [1] "2020-366"#> <year_day<day>[1]> #> [1] "2021-366"# Invalid dates are fine, as long as they are eventually resolved # by either manually resolving, or by calling `invalid_resolve()` # Resolve by returning the previous / next valid moment in time invalid_resolve(y_plus, invalid = "previous")#> <year_day<day>[1]> #> [1] "2021-365"#> <year_day<day>[1]> #> [1] "2022-001"# Manually resolve by setting to the last day of the year invalid <- invalid_detect(y_plus) y_plus[invalid] <- set_day(y_plus[invalid], "last") y_plus#> <year_day<day>[1]> #> [1] "2021-365"