calendar-align.RdAligns a "timeDate" object to regular date/time stamps.
# S4 method for class 'timeDate'
align(x, by = "1d", offset = "0s")
alignDaily(x, include.weekends=FALSE)
alignMonthly(x, include.weekends=FALSE)
alignQuarterly(x, include.weekends=FALSE)an object of class "timeDate".
a character string formed from an integer length and
a period identifier. Valid values are
"w", "d", "h", "m", "s", for
weeks, days, hours, minutes and seconds. For example
a bi-weekly period is expressed as "2w".
a character string to set an offset formed from an integer
length and a period identifier in the same way as for
argument by.
logical value indicating whether weekends should be included.
The functions alignDaily, alignMonthly,
alignMonthly are simple to use functions which
generate end-of-day, end-of-month, and end-of quarter
"timeDate" objects. Weekends are excluded by
default. Optionally they can be added setting the
argument include.weekends = TRUE.
an object of class "timeDate"
## align
# align bi-weekly with a 3 days offset
(tC <- timeCalendar())
#> GMT
#> [1] [2025-01-01] [2025-02-01] [2025-03-01] [2025-04-01] [2025-05-01]
#> [6] [2025-06-01] [2025-07-01] [2025-08-01] [2025-09-01] [2025-10-01]
#> [11] [2025-11-01] [2025-12-01]
align(tC, by = "2w", offset = "3d")
#> GMT
#> [1] [2025-01-04] [2025-01-18] [2025-02-01] [2025-02-15] [2025-03-01]
#> [6] [2025-03-15] [2025-03-29] [2025-04-12] [2025-04-26] [2025-05-10]
#> [11] [2025-05-24] [2025-06-07] [2025-06-21] [2025-07-05] [2025-07-19]
#> [16] [2025-08-02] [2025-08-16] [2025-08-30] [2025-09-13] [2025-09-27]
#> [21] [2025-10-11] [2025-10-25] [2025-11-08] [2025-11-22]
## alignDaily
# simple to use functions
alignDaily(tC)
#> GMT
#> [1] [2025-01-01] [2025-01-02] [2025-01-03] [2025-01-06] [2025-01-07]
#> [6] [2025-01-08] [2025-01-09] [2025-01-10] [2025-01-13] [2025-01-14]
#> [11] [2025-01-15] [2025-01-16] [2025-01-17] [2025-01-20] [2025-01-21]
#> [16] [2025-01-22] [2025-01-23] [2025-01-24] [2025-01-27] [2025-01-28]
#> [21] [2025-01-29] [2025-01-30] [2025-01-31] [2025-02-03] [2025-02-04]
#> [26] [2025-02-05] [2025-02-06] [2025-02-07] [2025-02-10] [2025-02-11]
#> [31] [2025-02-12] [2025-02-13] [2025-02-14] [2025-02-17] [2025-02-18]
#> [36] [2025-02-19] [2025-02-20] [2025-02-21] [2025-02-24] [2025-02-25]
#> [41] [2025-02-26] [2025-02-27] [2025-02-28] [2025-03-03] [2025-03-04]
#> [46] [2025-03-05] [2025-03-06] [2025-03-07] [2025-03-10] [2025-03-11]
#> [51] [2025-03-12] [2025-03-13] [2025-03-14] [2025-03-17] [2025-03-18]
#> [56] [2025-03-19] [2025-03-20] [2025-03-21] [2025-03-24] [2025-03-25]
#> [61] [2025-03-26] [2025-03-27] [2025-03-28] [2025-03-31] [2025-04-01]
#> [66] [2025-04-02] [2025-04-03] [2025-04-04] [2025-04-07] [2025-04-08]
#> [71] [2025-04-09] [2025-04-10] [2025-04-11] [2025-04-14] [2025-04-15]
#> [76] [2025-04-16] [2025-04-17] [2025-04-18] [2025-04-21] [2025-04-22]
#> [81] [2025-04-23] [2025-04-24] [2025-04-25] [2025-04-28] [2025-04-29]
#> [86] [2025-04-30] [2025-05-01] [2025-05-02] [2025-05-05] [2025-05-06]
#> [91] [2025-05-07] [2025-05-08] [2025-05-09] [2025-05-12] [2025-05-13]
#> [96] [2025-05-14] [2025-05-15] [2025-05-16] [2025-05-19] [2025-05-20]
#> ...
#> [ reached getRmetricsOption('max.print') | getOption('max.print') -- omitted 139 rows ]]
alignDaily(tC, include.weekends = TRUE)
#> GMT
#> [1] [2025-01-01] [2025-01-02] [2025-01-03] [2025-01-04] [2025-01-05]
#> [6] [2025-01-06] [2025-01-07] [2025-01-08] [2025-01-09] [2025-01-10]
#> [11] [2025-01-11] [2025-01-12] [2025-01-13] [2025-01-14] [2025-01-15]
#> [16] [2025-01-16] [2025-01-17] [2025-01-18] [2025-01-19] [2025-01-20]
#> [21] [2025-01-21] [2025-01-22] [2025-01-23] [2025-01-24] [2025-01-25]
#> [26] [2025-01-26] [2025-01-27] [2025-01-28] [2025-01-29] [2025-01-30]
#> [31] [2025-01-31] [2025-02-01] [2025-02-02] [2025-02-03] [2025-02-04]
#> [36] [2025-02-05] [2025-02-06] [2025-02-07] [2025-02-08] [2025-02-09]
#> [41] [2025-02-10] [2025-02-11] [2025-02-12] [2025-02-13] [2025-02-14]
#> [46] [2025-02-15] [2025-02-16] [2025-02-17] [2025-02-18] [2025-02-19]
#> [51] [2025-02-20] [2025-02-21] [2025-02-22] [2025-02-23] [2025-02-24]
#> [56] [2025-02-25] [2025-02-26] [2025-02-27] [2025-02-28] [2025-03-01]
#> [61] [2025-03-02] [2025-03-03] [2025-03-04] [2025-03-05] [2025-03-06]
#> [66] [2025-03-07] [2025-03-08] [2025-03-09] [2025-03-10] [2025-03-11]
#> [71] [2025-03-12] [2025-03-13] [2025-03-14] [2025-03-15] [2025-03-16]
#> [76] [2025-03-17] [2025-03-18] [2025-03-19] [2025-03-20] [2025-03-21]
#> [81] [2025-03-22] [2025-03-23] [2025-03-24] [2025-03-25] [2025-03-26]
#> [86] [2025-03-27] [2025-03-28] [2025-03-29] [2025-03-30] [2025-03-31]
#> [91] [2025-04-01] [2025-04-02] [2025-04-03] [2025-04-04] [2025-04-05]
#> [96] [2025-04-06] [2025-04-07] [2025-04-08] [2025-04-09] [2025-04-10]
#> ...
#> [ reached getRmetricsOption('max.print') | getOption('max.print') -- omitted 235 rows ]]
# align to end-of-month dates
alignMonthly(tC)
#> GMT
#> [1] [2025-01-31] [2025-02-28] [2025-03-31] [2025-04-30] [2025-05-30]
#> [6] [2025-06-30] [2025-07-31] [2025-08-30] [2025-09-30] [2025-10-31]
#> [11] [2025-11-29] [2025-12-31]