File: year-week-day-setters.Rd

package info (click to toggle)
r-cran-clock 0.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,856 kB
  • sloc: cpp: 19,564; sh: 17; makefile: 2
file content (81 lines) | stat: -rw-r--r-- 2,370 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/week-year-week-day.R
\name{year-week-day-setters}
\alias{year-week-day-setters}
\alias{set_year.clock_year_week_day}
\alias{set_week.clock_year_week_day}
\alias{set_day.clock_year_week_day}
\alias{set_hour.clock_year_week_day}
\alias{set_minute.clock_year_week_day}
\alias{set_second.clock_year_week_day}
\alias{set_millisecond.clock_year_week_day}
\alias{set_microsecond.clock_year_week_day}
\alias{set_nanosecond.clock_year_week_day}
\title{Setters: year-week-day}
\usage{
\method{set_year}{clock_year_week_day}(x, value, ...)

\method{set_week}{clock_year_week_day}(x, value, ...)

\method{set_day}{clock_year_week_day}(x, value, ...)

\method{set_hour}{clock_year_week_day}(x, value, ...)

\method{set_minute}{clock_year_week_day}(x, value, ...)

\method{set_second}{clock_year_week_day}(x, value, ...)

\method{set_millisecond}{clock_year_week_day}(x, value, ...)

\method{set_microsecond}{clock_year_week_day}(x, value, ...)

\method{set_nanosecond}{clock_year_week_day}(x, value, ...)
}
\arguments{
\item{x}{\verb{[clock_year_week_day]}

A year-week-day vector.}

\item{value}{\verb{[integer / "last"]}

The value to set the component to.

For \code{set_week()}, this can also be \code{"last"} to adjust to the last
week of the current year.}

\item{...}{These dots are for future extensions and must be empty.}
}
\value{
\code{x} with the component set.
}
\description{
These are year-week-day methods for the \link[=clock-setters]{setter generics}.
\itemize{
\item \code{set_year()} sets the year.
\item \code{set_week()} sets the week of the year. Valid values are in the range
of \verb{[1, 53]}.
\item \code{set_day()} sets the day of the week. Valid values are in the range of
\verb{[1, 7]}.
\item There are sub-daily setters for setting more precise components.
}
}
\examples{
# Year precision vector
x <- year_week_day(2019:2023)

# Promote to week precision by setting the week
# (Note that some 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")
}