duration

0th

Percentile

Create a duration object.

duration creates a duration object with the specified values. duration provides the behavior of new_duration in a way that is more suitable for automating within a function.

Keywords
classes, chron
Usage
duration(num = 0, units = "seconds")
Arguments
num
the number of time units to include in the duration
units
a character string that specifies the type of units that num refers to.
Details

Durations display as the number of seconds in a time span. When this number is large, durations also display an estimate in larger units,; however, the underlying object is always recorded as a fixed number of seconds. For display and creation purposes, units are converted to seconds using their most common lengths in seconds. Minutes = 60 seconds, hours = 3600 seconds, days = 86400 seconds, weeks = 604800.

Durations record the exact number of seconds in a time span. They measure the exact passage of time but do not always align with measurements made in larger units of time such as hours, months and years. This is because the length of larger time units can be affected by conventions such as leap years and Daylight Savings Time. Base R provides a second class for measuring durations, the difftime class.

Duration objects can be easily created with the helper functions dweeks, ddays, dminutes, dseconds. These objects can be added to and subtracted to date- times to create a user interface similar to object oriented programming.

Value

  • a duration object

See Also

new_duration, as.duration

Aliases
  • duration
Examples
duration(90, "seconds")
# 90s
duration(1.5, "minutes")
# 90s
duration(-1, "days")
# -86400s (~-1 days)
Documentation reproduced from package lubridate, version 1.3.0, License: GPL

Community examples

Looks like there are no examples yet.