time_update: Update components of a date-time object

Description Usage Arguments Value Examples

View source: R/update.R

Description

time_update returns a date-time with the specified elements updated. Elements not specified will be left unchanged.

Usage

1
2
3
4
time_update(time, updates = NULL, year = NULL, month = NULL,
  yday = NULL, day = NULL, mday = NULL, wday = NULL, hour = NULL,
  minute = NULL, second = NULL, tz = NULL, roll_month = "last",
  roll_dst = "boundary", week_start = getOption("week_start", 1))

Arguments

time

a date-time object

updates

a string specification of components to be updated (not implemented yet) or a named list of components.

year, month, yday, wday, mday, day, hour, minute, second

components of the date-time to be updated. day is equivalent to mday. All except second will be converted to integer.

tz

time zone component (a singleton character vector)

roll_month, roll_dst

See time_add().

week_start

week starting day (Default is 1, Monday). Set week_start option to change this globally.

Value

a date object with the requested elements updated. The object will retain its original class unless the original class is Date and at least one of the hour, minute, second or tz is supplied, in which case a POSIXct object is returned.

Examples

1
2
3
4
5
date <- as.Date("2009-02-10")
time_update(date, year = 2010, month = 1, mday = 1)
time_update(date, year = 2010, month = 13, mday = 1)
time_update(date, minute = 10, second = 3)
time_update(date, minute = 10, second = 3, tz = "America/New_York")

timechange documentation built on April 26, 2018, 5:04 p.m.