Get the event dates or datetimes from a schedule.
schedule(x, from = NULL, to = NULL, during = NULL, period_type = "day", n = 1) schedule_days(x, from = NULL, to = NULL, during = NULL) schedule_hours(x, from = NULL, to = NULL, during = NULL) schedule_next_days(x, n, from, limit = lubridate::years(1))
| x | A schedule object. |
|---|---|
| from, to, during | The limits to place on the output (see Details). |
| period_type | The period type of the output. Eg. "day" (the default),
"hour" etc. Can be any unit accepted by |
| n | The increment of the period type. Eg. for events occurring every
half-hour the |
A date or datetime object.
schedule_days() is a convenience function for schedule() where
period_type is pre-filled as "day". Likewise for schedule_hours(),
where period_type is pre-filled as "hour". These functions are
recommended as they cover the most common use cases.
The from and to arguments set limits on the output.
They are only required when the schedule x doesn't
have implicit limits (and therefore has an infinite number of possible
events).
from and to can each be either:
a single date or datetime value or,
A numeric year.
In the case of from, a numeric year translates to the
start date of the year eg. from = 2000 translates to
as.Date("2000-01-01").
In the case of to it translates to the end of the year eg.
to = 2001 translates to as.Date("2001-12-31").
during is a shortcut for when setting a single year limit. Eg.
during = 2000 is the equivalent of setting from = as.Date("2000-01-01")
and to = as.Date("2000-12-31").
library(magrittr) on_paydays <- on_mday(25) schedule_days(on_paydays, from = as.Date("2000-06-01"), to = as.Date("2000-12-01"))#> [1] "2000-06-25" "2000-07-25" "2000-08-25" "2000-09-25" "2000-10-25" #> [6] "2000-11-25"schedule_days(on_paydays, from = 2000, to = 2001)#> [1] "2000-01-25" "2000-02-25" "2000-03-25" "2000-04-25" "2000-05-25" #> [6] "2000-06-25" "2000-07-25" "2000-08-25" "2000-09-25" "2000-10-25" #> [11] "2000-11-25" "2000-12-25" "2001-01-25" "2001-02-25" "2001-03-25" #> [16] "2001-04-25" "2001-05-25" "2001-06-25" "2001-07-25" "2001-08-25" #> [21] "2001-09-25" "2001-10-25" "2001-11-25" "2001-12-25"schedule_days(on_paydays, during = 2000)#> [1] "2000-01-25" "2000-02-25" "2000-03-25" "2000-04-25" "2000-05-25" #> [6] "2000-06-25" "2000-07-25" "2000-08-25" "2000-09-25" "2000-10-25" #> [11] "2000-11-25" "2000-12-25"on_jan_paydays <- only_occur(on_paydays, in_month("Jan")) schedule_hours(on_jan_paydays, during = 2000)#> [1] "2000-01-25 00:00:00 UTC" "2000-01-25 01:00:00 UTC" #> [3] "2000-01-25 02:00:00 UTC" "2000-01-25 03:00:00 UTC" #> [5] "2000-01-25 04:00:00 UTC" "2000-01-25 05:00:00 UTC" #> [7] "2000-01-25 06:00:00 UTC" "2000-01-25 07:00:00 UTC" #> [9] "2000-01-25 08:00:00 UTC" "2000-01-25 09:00:00 UTC" #> [11] "2000-01-25 10:00:00 UTC" "2000-01-25 11:00:00 UTC" #> [13] "2000-01-25 12:00:00 UTC" "2000-01-25 13:00:00 UTC" #> [15] "2000-01-25 14:00:00 UTC" "2000-01-25 15:00:00 UTC" #> [17] "2000-01-25 16:00:00 UTC" "2000-01-25 17:00:00 UTC" #> [19] "2000-01-25 18:00:00 UTC" "2000-01-25 19:00:00 UTC" #> [21] "2000-01-25 20:00:00 UTC" "2000-01-25 21:00:00 UTC" #> [23] "2000-01-25 22:00:00 UTC" "2000-01-25 23:00:00 UTC"on_jan_payday_2002 <- on_paydays %>% only_occur(in_month("Jan")) %>% only_occur(in_year(2002)) ## No limits required schedule_days(on_jan_payday_2002)#> [1] "2002-01-25"schedule_hours(on_jan_payday_2002)#> [1] "2002-01-25 00:00:00 UTC" "2002-01-25 01:00:00 UTC" #> [3] "2002-01-25 02:00:00 UTC" "2002-01-25 03:00:00 UTC" #> [5] "2002-01-25 04:00:00 UTC" "2002-01-25 05:00:00 UTC" #> [7] "2002-01-25 06:00:00 UTC" "2002-01-25 07:00:00 UTC" #> [9] "2002-01-25 08:00:00 UTC" "2002-01-25 09:00:00 UTC" #> [11] "2002-01-25 10:00:00 UTC" "2002-01-25 11:00:00 UTC" #> [13] "2002-01-25 12:00:00 UTC" "2002-01-25 13:00:00 UTC" #> [15] "2002-01-25 14:00:00 UTC" "2002-01-25 15:00:00 UTC" #> [17] "2002-01-25 16:00:00 UTC" "2002-01-25 17:00:00 UTC" #> [19] "2002-01-25 18:00:00 UTC" "2002-01-25 19:00:00 UTC" #> [21] "2002-01-25 20:00:00 UTC" "2002-01-25 21:00:00 UTC" #> [23] "2002-01-25 22:00:00 UTC" "2002-01-25 23:00:00 UTC"schedule(on_jan_payday_2002, period_type = "minute", n = 30)#> [1] "2002-01-25 00:00:00 UTC" "2002-01-25 00:30:00 UTC" #> [3] "2002-01-25 01:00:00 UTC" "2002-01-25 01:30:00 UTC" #> [5] "2002-01-25 02:00:00 UTC" "2002-01-25 02:30:00 UTC" #> [7] "2002-01-25 03:00:00 UTC" "2002-01-25 03:30:00 UTC" #> [9] "2002-01-25 04:00:00 UTC" "2002-01-25 04:30:00 UTC" #> [11] "2002-01-25 05:00:00 UTC" "2002-01-25 05:30:00 UTC" #> [13] "2002-01-25 06:00:00 UTC" "2002-01-25 06:30:00 UTC" #> [15] "2002-01-25 07:00:00 UTC" "2002-01-25 07:30:00 UTC" #> [17] "2002-01-25 08:00:00 UTC" "2002-01-25 08:30:00 UTC" #> [19] "2002-01-25 09:00:00 UTC" "2002-01-25 09:30:00 UTC" #> [21] "2002-01-25 10:00:00 UTC" "2002-01-25 10:30:00 UTC" #> [23] "2002-01-25 11:00:00 UTC" "2002-01-25 11:30:00 UTC" #> [25] "2002-01-25 12:00:00 UTC" "2002-01-25 12:30:00 UTC" #> [27] "2002-01-25 13:00:00 UTC" "2002-01-25 13:30:00 UTC" #> [29] "2002-01-25 14:00:00 UTC" "2002-01-25 14:30:00 UTC" #> [31] "2002-01-25 15:00:00 UTC" "2002-01-25 15:30:00 UTC" #> [33] "2002-01-25 16:00:00 UTC" "2002-01-25 16:30:00 UTC" #> [35] "2002-01-25 17:00:00 UTC" "2002-01-25 17:30:00 UTC" #> [37] "2002-01-25 18:00:00 UTC" "2002-01-25 18:30:00 UTC" #> [39] "2002-01-25 19:00:00 UTC" "2002-01-25 19:30:00 UTC" #> [41] "2002-01-25 20:00:00 UTC" "2002-01-25 20:30:00 UTC" #> [43] "2002-01-25 21:00:00 UTC" "2002-01-25 21:30:00 UTC" #> [45] "2002-01-25 22:00:00 UTC" "2002-01-25 22:30:00 UTC" #> [47] "2002-01-25 23:00:00 UTC" "2002-01-25 23:30:00 UTC"