Here are the examples and how they would be run in gs
.
In most of the example (unless otherwise stated) the start date is 1997-09-02. At 9am.
Daily for 10 occurrences:
on_every("day", starting = ymd("1997-09-02")) %>%
only_occur(on_or_after(ymd("1997-09-02"))) %>%
schedule_days(during = 1997) %>%
head(10)
#> [1] "1997-09-02" "1997-09-03" "1997-09-04" "1997-09-05" "1997-09-06"
#> [6] "1997-09-07" "1997-09-08" "1997-09-09" "1997-09-10" "1997-09-11"
Daily until December 24, 1997:
on_every("day", starting = ymd("1997-09-02")) %>%
only_occur(on_or_after(ymd("1997-09-02"))) %>%
only_occur(before(dmy("24-12-1997"))) %>%
schedule_days()
#> [1] "1997-09-02" "1997-09-03" "1997-09-04" "1997-09-05" "1997-09-06"
#> [6] "1997-09-07" "1997-09-08" "1997-09-09" "1997-09-10" "1997-09-11"
#> [11] "1997-09-12" "1997-09-13" "1997-09-14" "1997-09-15" "1997-09-16"
#> [16] "1997-09-17" "1997-09-18" "1997-09-19" "1997-09-20" "1997-09-21"
#> [21] "1997-09-22" "1997-09-23" "1997-09-24" "1997-09-25" "1997-09-26"
#> [26] "1997-09-27" "1997-09-28" "1997-09-29" "1997-09-30" "1997-10-01"
#> [31] "1997-10-02" "1997-10-03" "1997-10-04" "1997-10-05" "1997-10-06"
#> [36] "1997-10-07" "1997-10-08" "1997-10-09" "1997-10-10" "1997-10-11"
#> [41] "1997-10-12" "1997-10-13" "1997-10-14" "1997-10-15" "1997-10-16"
#> [46] "1997-10-17" "1997-10-18" "1997-10-19" "1997-10-20" "1997-10-21"
#> [51] "1997-10-22" "1997-10-23" "1997-10-24" "1997-10-25" "1997-10-26"
#> [56] "1997-10-27" "1997-10-28" "1997-10-29" "1997-10-30" "1997-10-31"
#> [61] "1997-11-01" "1997-11-02" "1997-11-03" "1997-11-04" "1997-11-05"
#> [66] "1997-11-06" "1997-11-07" "1997-11-08" "1997-11-09" "1997-11-10"
#> [71] "1997-11-11" "1997-11-12" "1997-11-13" "1997-11-14" "1997-11-15"
#> [76] "1997-11-16" "1997-11-17" "1997-11-18" "1997-11-19" "1997-11-20"
#> [81] "1997-11-21" "1997-11-22" "1997-11-23" "1997-11-24" "1997-11-25"
#> [86] "1997-11-26" "1997-11-27" "1997-11-28" "1997-11-29" "1997-11-30"
#> [91] "1997-12-01" "1997-12-02" "1997-12-03" "1997-12-04" "1997-12-05"
#> [96] "1997-12-06" "1997-12-07" "1997-12-08" "1997-12-09" "1997-12-10"
#> [101] "1997-12-11" "1997-12-12" "1997-12-13" "1997-12-14" "1997-12-15"
#> [106] "1997-12-16" "1997-12-17" "1997-12-18" "1997-12-19" "1997-12-20"
#> [111] "1997-12-21" "1997-12-22" "1997-12-23"
Every other day - forever:
on_every_second("day", starting = ymd("1997-09-02")) %>%
schedule_days(during = 1997)
#> [1] "1997-09-02" "1997-09-04" "1997-09-06" "1997-09-08" "1997-09-10"
#> [6] "1997-09-12" "1997-09-14" "1997-09-16" "1997-09-18" "1997-09-20"
#> [11] "1997-09-22" "1997-09-24" "1997-09-26" "1997-09-28" "1997-09-30"
#> [16] "1997-10-02" "1997-10-04" "1997-10-06" "1997-10-08" "1997-10-10"
#> [21] "1997-10-12" "1997-10-14" "1997-10-16" "1997-10-18" "1997-10-20"
#> [26] "1997-10-22" "1997-10-24" "1997-10-26" "1997-10-28" "1997-10-30"
#> [31] "1997-11-01" "1997-11-03" "1997-11-05" "1997-11-07" "1997-11-09"
#> [36] "1997-11-11" "1997-11-13" "1997-11-15" "1997-11-17" "1997-11-19"
#> [41] "1997-11-21" "1997-11-23" "1997-11-25" "1997-11-27" "1997-11-29"
#> [46] "1997-12-01" "1997-12-03" "1997-12-05" "1997-12-07" "1997-12-09"
#> [51] "1997-12-11" "1997-12-13" "1997-12-15" "1997-12-17" "1997-12-19"
#> [56] "1997-12-21" "1997-12-23" "1997-12-25" "1997-12-27" "1997-12-29"
#> [61] "1997-12-31"
Every 10 days, 5 occurrences:
on_every_nth(10, "days", starting = ymd("1997-09-02")) %>%
schedule_days(during = 1997) %>%
head(5)
#> [1] "1997-09-02" "1997-09-12" "1997-09-22" "1997-10-02" "1997-10-12"
Every day in January, for 3 years:
in_month("Jan") %>%
only_occur(in_year(1999:2000)) %>%
schedule_days()
#> [1] "1999-01-01" "1999-01-02" "1999-01-03" "1999-01-04" "1999-01-05"
#> [6] "1999-01-06" "1999-01-07" "1999-01-08" "1999-01-09" "1999-01-10"
#> [11] "1999-01-11" "1999-01-12" "1999-01-13" "1999-01-14" "1999-01-15"
#> [16] "1999-01-16" "1999-01-17" "1999-01-18" "1999-01-19" "1999-01-20"
#> [21] "1999-01-21" "1999-01-22" "1999-01-23" "1999-01-24" "1999-01-25"
#> [26] "1999-01-26" "1999-01-27" "1999-01-28" "1999-01-29" "1999-01-30"
#> [31] "1999-01-31" "2000-01-01" "2000-01-02" "2000-01-03" "2000-01-04"
#> [36] "2000-01-05" "2000-01-06" "2000-01-07" "2000-01-08" "2000-01-09"
#> [41] "2000-01-10" "2000-01-11" "2000-01-12" "2000-01-13" "2000-01-14"
#> [46] "2000-01-15" "2000-01-16" "2000-01-17" "2000-01-18" "2000-01-19"
#> [51] "2000-01-20" "2000-01-21" "2000-01-22" "2000-01-23" "2000-01-24"
#> [56] "2000-01-25" "2000-01-26" "2000-01-27" "2000-01-28" "2000-01-29"
#> [61] "2000-01-30" "2000-01-31"
Weekly for 10 occurrences:
on_every("week", starting = ymd("1997-09-02")) %>%
schedule_days(during = 1997) %>%
head(10)
#> [1] "1997-09-02" "1997-09-09" "1997-09-16" "1997-09-23" "1997-09-30"
#> [6] "1997-10-07" "1997-10-14" "1997-10-21" "1997-10-28" "1997-11-04"
Weekly until December 24, 1997:
on_every("week", starting = ymd("1997-09-02")) %>%
only_occur(before(ymd("1997-12-24"))) %>%
schedule_days(during = 1997)
#> [1] "1997-09-02" "1997-09-09" "1997-09-16" "1997-09-23" "1997-09-30"
#> [6] "1997-10-07" "1997-10-14" "1997-10-21" "1997-10-28" "1997-11-04"
#> [11] "1997-11-11" "1997-11-18" "1997-11-25" "1997-12-02" "1997-12-09"
#> [16] "1997-12-16" "1997-12-23"
Every other week - forever:
on_every_second("week", starting = ymd("1997-09-02")) %>%
schedule_days(from = 1997, to = 1998)
#> [1] "1997-09-02" "1997-09-16" "1997-09-30" "1997-10-14" "1997-10-28"
#> [6] "1997-11-11" "1997-11-25" "1997-12-09" "1997-12-23" "1998-01-06"
#> [11] "1998-01-20" "1998-02-03" "1998-02-17" "1998-03-03" "1998-03-17"
#> [16] "1998-03-31" "1998-04-14" "1998-04-28" "1998-05-12" "1998-05-26"
#> [21] "1998-06-09" "1998-06-23" "1998-07-07" "1998-07-21" "1998-08-04"
#> [26] "1998-08-18" "1998-09-01" "1998-09-15" "1998-09-29" "1998-10-13"
#> [31] "1998-10-27" "1998-11-10" "1998-11-24" "1998-12-08" "1998-12-22"
Weekly on Tuesday and Thursday for five weeks:
on_wday("Tue", "Thu") %>%
only_occur(on_or_after(ymd("1997-09-02"))) %>%
schedule_days(to = ymd("1997-09-02") + weeks(5))
#> [1] "1997-09-02" "1997-09-04" "1997-09-09" "1997-09-11" "1997-09-16"
#> [6] "1997-09-18" "1997-09-23" "1997-09-25" "1997-09-30" "1997-10-02"
#> [11] "1997-10-07"
There is a difference here. The gs
result stretches one further than iCal to include “1997-10-07”.
Every other week on Monday, Wednesday, and Friday until December 24, 1997, starting on Monday, September 1, 1997:
in_every_second("week", starting = ymd("1997-09-01")) %>%
only_occur(on_or_before(ymd("1997-12-24"))) %>%
schedule_days(during = 1997)
#> [1] "1997-09-01" "1997-09-02" "1997-09-10" "1997-09-11" "1997-09-12"
#> [6] "1997-09-13" "1997-09-14" "1997-09-15" "1997-09-16" "1997-09-24"
#> [11] "1997-09-25" "1997-09-26" "1997-09-27" "1997-09-28" "1997-09-29"
#> [16] "1997-09-30" "1997-10-08" "1997-10-09" "1997-10-10" "1997-10-11"
#> [21] "1997-10-12" "1997-10-13" "1997-10-14" "1997-10-22" "1997-10-23"
#> [26] "1997-10-24" "1997-10-25" "1997-10-26" "1997-10-27" "1997-10-28"
#> [31] "1997-11-05" "1997-11-06" "1997-11-07" "1997-11-08" "1997-11-09"
#> [36] "1997-11-10" "1997-11-11" "1997-11-19" "1997-11-20" "1997-11-21"
#> [41] "1997-11-22" "1997-11-23" "1997-11-24" "1997-11-25" "1997-12-03"
#> [46] "1997-12-04" "1997-12-05" "1997-12-06" "1997-12-07" "1997-12-08"
#> [51] "1997-12-09" "1997-12-17" "1997-12-18" "1997-12-19" "1997-12-20"
#> [56] "1997-12-21" "1997-12-22" "1997-12-23"
Every other week on Tuesday and Thursday, for 8 occurrences:
Monthly on the first Friday for 10 occurrences:
Monthly on the first Friday until December 24, 1997:
Every other month on the first and last Sunday of the month for 10 occurrences:
Monthly on the second-to-last Monday of the month for 6 months:
start_date <- ymd("1997-09-02")
on_nth(-2, on_wday("Mon"), within_given = "month") %>%
only_occur(on_or_after(start_date)) %>%
only_occur(on_or_before(start_date + months(6))) %>%
schedule_days(from = 1997, to = 1998)
#> [1] "1997-09-22" "1997-10-20" "1997-11-17" "1997-12-22" "1998-01-19"
#> [6] "1998-02-16"
Monthly on the third-to-the-last day of the month, forever:
Monthly on the 2nd and 15th of the month for 10 occurrences:
Monthly on the first and last day of the month for 10 occurrences:
Every 18 months on the 10th thru 15th of the month for 10 occurrences:
Every Tuesday, every other month:
Yearly in June and July for 10 occurrences:
Every other year on January, February, and March for 10 occurrences:
Every third year on the 1st, 100th, and 200th day for 10 occurrences:
Every 20th Monday of the year, forever:
on_nth(20, on_wday("Mon"), within_given = "year") %>%
schedule_days(from = 1997, to = 1999)
#> [1] "1997-05-19" "1998-05-18" "1999-05-17"
Monday of week number 20 (where the default start of the week is Monday), forever:
in_isoweek(20) %>%
only_occur(on_wday("Monday")) %>%
schedule_days(from = 1997, to = 1999)
#> [1] "1997-05-12" "1998-05-11" "1999-05-17"
Every Thursday in March, forever:
on_wday("Thu") %>%
only_occur(in_month("Mar")) %>%
schedule_days(from = ymd("1997-03-13"), to = 1999)
#> [1] "1997-03-13" "1997-03-20" "1997-03-27" "1998-03-05" "1998-03-12"
#> [6] "1998-03-19" "1998-03-26" "1999-03-04" "1999-03-11" "1999-03-18"
#> [11] "1999-03-25"
Every Thursday, but only during June, July, and August, forever:
in_month("Jun", "Jul", "Aug") %>%
only_occur(on_wday("Thu")) %>%
schedule_days(from = ymd("1997-06-05"), to = 1999)
#> [1] "1997-06-05" "1997-06-12" "1997-06-19" "1997-06-26" "1997-07-03"
#> [6] "1997-07-10" "1997-07-17" "1997-07-24" "1997-07-31" "1997-08-07"
#> [11] "1997-08-14" "1997-08-21" "1997-08-28" "1998-06-04" "1998-06-11"
#> [16] "1998-06-18" "1998-06-25" "1998-07-02" "1998-07-09" "1998-07-16"
#> [21] "1998-07-23" "1998-07-30" "1998-08-06" "1998-08-13" "1998-08-20"
#> [26] "1998-08-27" "1999-06-03" "1999-06-10" "1999-06-17" "1999-06-24"
#> [31] "1999-07-01" "1999-07-08" "1999-07-15" "1999-07-22" "1999-07-29"
#> [36] "1999-08-05" "1999-08-12" "1999-08-19" "1999-08-26"
Every Friday the 13th, forever:
on_wday("Fri") %>%
only_occur(on_mday(13)) %>%
schedule(from = ymd("1997-09-02"), to = 2000)
#> [1] "1998-02-13" "1998-03-13" "1998-11-13" "1999-08-13" "2000-10-13"
The first Saturday that follows the first Sunday of the month, forever:
on_first(on_wday("Sun"), within_given = "month") %>%
roll_forward(to_schedule = on_wday("Sat")) %>%
schedule_days(from = ymd("1997-09-13"), to = 1998)
#> [1] "1997-09-13" "1997-10-11" "1997-11-08" "1997-12-13" "1998-01-10"
#> [6] "1998-02-07" "1998-03-07" "1998-04-11" "1998-05-09" "1998-06-13"
#> [11] "1998-07-11" "1998-08-08" "1998-09-12" "1998-10-10" "1998-11-07"
#> [16] "1998-12-12"
Every 4 years, the first Tuesday after a Monday in November, forever (U.S. Presidential Election day):
The third instance into the month of one of Tuesday, Wednesday, or Thursday, for the next 3 months:
The second-to-last weekday of the month:
Every 3 hours from 9:00 AM to 5:00 PM on a specific day:
Every 15 minutes for 6 occurrences:
Every hour and a half for 4 occurrences:
Every 20 minutes from 9:00 AM to 4:40 PM every day:
There are a few examples I need to express in words.