messy_datetime_tzones: Change the timezone of datetime columns

View source: R/messy_dates.R

messy_datetime_tzonesR Documentation

Change the timezone of datetime columns

Description

Takes any number of datetime columns and changes their timezones either totally at random, or from a user-provided list of timezones.

Usage

messy_datetime_tzones(data, cols = NULL, tzones = OlsonNames(), force = FALSE)

Arguments

data

input dataframe

cols

set of columns to apply transformation to. If NULL will apply to all POSIXt columns.

tzones

Valid time zones to sample from. By default samples from all OlsonNames(), but can be set to options more relevant to the data.

force

By default (force = FALSE) the datetimes will have their actual hour/minute values changed along with the timezones. If force = TRUE, which requires lubridate, the datetime values will remain the same and only the timezone will differ.

Value

a dataframe the same size as the input data.

Author(s)

Jack Davison

See Also

Other Messy date(time) functions: messy_datetime_formats(), split_datetimes()

Examples

data <- data.frame(dates = rep(Sys.time(), 10))

data$dates
attr(data$dates, "tzone")

messy <- messy_datetime_tzones(data, tzones = "Poland")
messy$dates
attr(messy$dates, "tzone")


messy documentation built on April 3, 2025, 6:16 p.m.