iso-year-week-day-setters {clock}R Documentation

Setters: iso-year-week-day

Description

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

Usage

## S3 method for class 'clock_iso_year_week_day'
set_year(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_week(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_day(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_hour(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_minute(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_second(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_millisecond(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_microsecond(x, value, ...)

## S3 method for class 'clock_iso_year_week_day'
set_nanosecond(x, value, ...)

Arguments

x

⁠[clock_iso_year_week_day]⁠

A iso-year-week-day vector.

value

⁠[integer / "last"]⁠

The value to set the component to.

For set_week(), this can also be "last" to adjust to the last week of the current ISO year.

...

These dots are for future extensions and must be empty.

Value

x with the component set.

Examples

# Year precision vector
x <- iso_year_week_day(2019:2023)

# Promote to week precision by setting the week
# (Note that some ISO weeks have 52 weeks, and others have 53)
x <- set_week(x, "last")
x

# Set to an invalid week
invalid <- set_week(x, 53)
invalid

# Here are the invalid ones (they only have 52 weeks)
invalid[invalid_detect(invalid)]

# Resolve the invalid dates by choosing the previous/next valid moment
invalid_resolve(invalid, invalid = "previous")
invalid_resolve(invalid, invalid = "next")

[Package clock version 0.6.0 Index]