File: year-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 (76 lines) | stat: -rw-r--r-- 1,961 bytes parent folder | download | duplicates (2)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gregorian-year-day.R
\name{year-day-setters}
\alias{year-day-setters}
\alias{set_year.clock_year_day}
\alias{set_day.clock_year_day}
\alias{set_hour.clock_year_day}
\alias{set_minute.clock_year_day}
\alias{set_second.clock_year_day}
\alias{set_millisecond.clock_year_day}
\alias{set_microsecond.clock_year_day}
\alias{set_nanosecond.clock_year_day}
\title{Setters: year-day}
\usage{
\method{set_year}{clock_year_day}(x, value, ...)

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

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

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

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

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

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

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

A year-day vector.}

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

The value to set the component to.

For \code{set_day()}, this can also be \code{"last"} to set the day to the
last day of the year.}

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

# Set the day
set_day(x, 12:14)

# Set to the "last" day of the year
set_day(x, "last")

# Set to an invalid day of the year
invalid <- set_day(x, 366)
invalid

# Then resolve the invalid day by choosing the next valid day
invalid_resolve(invalid, invalid = "next")

# Cannot set a component two levels more precise than where you currently are
try(set_hour(x, 5))
}