# clock-arithmetic: Clock arithmetic In clock: Date-Time Types and Tools

## Description

This is the landing page for all clock arithmetic functions. There are specific sub-pages describing how arithmetic works for different calendars and time points, which is where you should look for more information.

Calendars are efficient at arithmetic with irregular units of time, such as month, quarters, or years.

• year-month-day

• year-month-weekday

• year-quarter-day

• iso-year-week-day

• year-day

Time points, such as naive-times and sys-times, are efficient at arithmetic with regular, well-defined units of time, such as days, hours, seconds, or nanoseconds.

• time-point

Durations can use any of these arithmetic functions, and return a new duration with a precision corresponding to the common type of the input and the function used.

• duration

Weekdays can perform day-based circular arithmetic.

• weekday

There are also convenience methods for doing arithmetic directly on a native R date or date-time type:

• dates (Date)

• date-times (POSIXct / POSIXlt)

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21``` ```add_years(x, n, ...) add_quarters(x, n, ...) add_months(x, n, ...) add_weeks(x, n, ...) add_days(x, n, ...) add_hours(x, n, ...) add_minutes(x, n, ...) add_seconds(x, n, ...) add_milliseconds(x, n, ...) add_microseconds(x, n, ...) add_nanoseconds(x, n, ...) ```

## Arguments

 `x` `[object]` An object. `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

Months and years are considered "irregular" because some months have more days then others (28, 29, 30, or 31), and some years have more days than others (365 or 366).

Days are considered "regular" because they are defined as 86,400 seconds.

## Value

`x` after performing the arithmetic.

## Examples

 ```1 2 3``` ```# See each sub-page for more specific examples x <- year_month_day(2019, 2, 1) add_months(x, 1) ```

clock documentation built on April 23, 2021, 1:06 a.m.