# months, resulution 2m
(ms <- tind(y = 2023, m = 1 + 2 * (0:5)))
is.regular(ms)
extend_regular(ms, 3)
(ms <- tind(y = 2023, m = c(1, 3, 5, 9)))
is.regular(ms)
as.regular(ms)
# date, resulution 15d
(ds <- tind(y = 2024, m = rep(1:3, each = 2), d = c(1, 16)))
is.regular(ds)
extend_regular(ds, -4)
(ds <- ds[-2L])
is.regular(ds)
as.regular(ds)
# corner cases
tz <- "Europe/Warsaw"
if (tz %in% OlsonNames()) {
# switch to DST
print(hours_in_day("2025-03-30", tz = tz))
# this will work with step from 1am to 3am
tt <- date_time("2025-03-30", H = c(0, 4:8), tz = tz)
print(resolution_t(tt))
as.regular(tt)
}
if (tz %in% OlsonNames()) {
# this will fail due to missing 2am
tt <- date_time("2025-03-30", H = c(0, 4, 6, 8), tz = tz)
print(resolution_t(tt))
try(as.regular(tt))
}
if (tz %in% OlsonNames()) {
# this will work again (step by 4h)
tt <- date_time("2025-03-30", H = c(0, 4, 12), tz = tz)
print(resolution_t(tt))
as.regular(tt)
}
Run the code above in your browser using DataLab