R Under development (unstable) (2026-08-05 r90355) -- "Unsuffered Consequences" Copyright (C) 2026 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "almanac" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('almanac') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("adjustments") > ### * adjustments > > flush(stderr()); flush(stdout()) > > ### Name: adjustments > ### Title: Date adjustments > ### Aliases: adjustments adj_following adj_preceding adj_modified_following > ### adj_modified_preceding adj_nearest adj_none > > ### ** Examples > > # A Saturday > x <- as.Date("1970-01-03") > > on_weekends <- weekly() %>% recur_on_weekends() > > # Adjust forward to Monday > adj_following(x, on_weekends) [1] "1970-01-05" > > # Adjust backwards to Friday > adj_preceding(x, on_weekends) [1] "1970-01-02" > > # Adjust to nearest non-event date > adj_nearest(x, on_weekends) [1] "1970-01-02" > adj_nearest(x + 1, on_weekends) [1] "1970-01-05" > > # Sundays, one of which is at the end of the month > sundays <- as.Date(c("2020-05-24", "2020-05-31")) > > # Adjust forward, unless that takes us into a new month, in which case we > # adjust backwards. > adj_modified_following(sundays, on_weekends) [1] "2020-05-25" "2020-05-29" > > # Saturdays, one of which is at the beginning of the month > saturdays <- as.Date(c("2020-08-01", "2020-08-08")) > > # Adjust backwards, unless that takes us into a new month, in which > # case we adjust forwards > adj_modified_preceding(saturdays, on_weekends) [1] "2020-08-03" "2020-08-07" > > > > cleanEx() > nameEx("alma_events") > ### * alma_events > > flush(stderr()); flush(stdout()) > > ### Name: alma_events > ### Title: Get all events > ### Aliases: alma_events > > ### ** Examples > > rrule <- daily(since = "1970-01-01", until = "1970-01-05") > > alma_events(rrule) [1] "1970-01-01" "1970-01-02" "1970-01-03" "1970-01-04" "1970-01-05" > > on_christmas <- yearly() %>% + recur_on_month_of_year("Dec") %>% + recur_on_day_of_month(25) > > alma_events(on_christmas, year = c(2020, 2022)) [1] "2020-12-25" "2022-12-25" > > > > cleanEx() > nameEx("alma_in") > ### * alma_in > > flush(stderr()); flush(stdout()) > > ### Name: alma_in > ### Title: Check if dates are in an event set > ### Aliases: alma_in > > ### ** Examples > > rrule <- weekly() %>% + recur_on_day_of_week("Thursday") > > # A Thursday and Friday > x <- as.Date("1970-01-01") + 0:1 > > alma_in(x, rrule) [1] TRUE FALSE > > # Every month, on the 2nd day of the month > rrule2 <- monthly() %>% + recur_on_day_of_month(2) > > # Make a larger set of multiple rules > rb <- runion(rrule, rrule2) > > alma_in(x, rb) [1] TRUE TRUE > > > > cleanEx() > nameEx("alma_next") > ### * alma_next > > flush(stderr()); flush(stdout()) > > ### Name: alma_next > ### Title: Generate the next or previous event > ### Aliases: alma_next alma_previous > > ### ** Examples > > on_12th <- monthly() %>% recur_on_day_of_month(12) > on_monday <- weekly() %>% recur_on_day_of_week("Monday") > > # On the 12th of the month, or on Mondays > rb <- runion(on_12th, on_monday) > > alma_next(c("2019-01-01", "2019-01-11"), rb) [1] "2019-01-07" "2019-01-12" > alma_previous(c("2019-01-01", "2019-01-11"), rb) [1] "2018-12-31" "2019-01-07" > > > > cleanEx() > nameEx("alma_search") > ### * alma_search > > flush(stderr()); flush(stdout()) > > ### Name: alma_search > ### Title: Search for events > ### Aliases: alma_search > > ### ** Examples > > on_12th <- monthly() %>% recur_on_day_of_month(12) > on_monday <- weekly() %>% recur_on_day_of_week("Monday") > > # On the 12th of the month, or on Mondays > rb <- runion(on_12th, on_monday) > > alma_search("2019-01-01", "2019-01-31", rb) [1] "2019-01-07" "2019-01-12" "2019-01-14" "2019-01-21" "2019-01-28" > > > > cleanEx() > nameEx("alma_seq") > ### * alma_seq > > flush(stderr()); flush(stdout()) > > ### Name: alma_seq > ### Title: Generate date sequences > ### Aliases: alma_seq > > ### ** Examples > > on_weekends <- weekly() %>% recur_on_weekends() > > # Generate a sequence of all non-weekend dates in Jan-2000 > alma_seq("2000-01-01", "2000-01-31", on_weekends) [1] "2000-01-03" "2000-01-04" "2000-01-05" "2000-01-06" "2000-01-07" [6] "2000-01-10" "2000-01-11" "2000-01-12" "2000-01-13" "2000-01-14" [11] "2000-01-17" "2000-01-18" "2000-01-19" "2000-01-20" "2000-01-21" [16] "2000-01-24" "2000-01-25" "2000-01-26" "2000-01-27" "2000-01-28" [21] "2000-01-31" > > > > cleanEx() > nameEx("alma_step") > ### * alma_step > > flush(stderr()); flush(stdout()) > > ### Name: alma_step > ### Title: Step relative to an rschedule > ### Aliases: alma_step > > ### ** Examples > > # Make a rrule for weekends > on_weekends <- weekly() %>% + recur_on_weekends() > > # "Step forward by 2 business days" > # 2019-09-13 is a Friday. > # Here we: > # - Step 1 day to Saturday > # - Adjust to Monday > # - Step 1 day to Tuesday > alma_step("2019-09-13", 2, on_weekends) [1] "2019-09-17" > > # If Monday, 2019-09-16, was a recurring holiday, we could create > # a custom runion and step over that too. > on_09_16 <- yearly() %>% + recur_on_month_of_year(9) %>% + recur_on_day_of_month(16) > > rb <- runion(on_09_16, on_weekends) > > alma_step("2019-09-13", 2, rb) [1] "2019-09-18" > > > > cleanEx() > nameEx("almanac-defaults") > ### * almanac-defaults > > flush(stderr()); flush(stdout()) > > ### Name: almanac-defaults > ### Title: Default values in almanac > ### Aliases: almanac-defaults almanac_since almanac_until > > ### ** Examples > > almanac_since() [1] "1900-01-01" > almanac_until() [1] "2100-01-01" > > > > cleanEx() > nameEx("almanac-vctrs-compat") > ### * almanac-vctrs-compat > > flush(stderr()); flush(stdout()) > > ### Name: almanac-vctrs-compat > ### Title: vctrs compatibility functions > ### Aliases: almanac-vctrs-compat vec_arith.almanac_stepper > ### vec_ptype2.almanac_stepper.almanac_stepper > ### vec_cast.almanac_stepper.almanac_stepper > ### Keywords: internal > > ### ** Examples > > library(vctrs) > vec_arith("+", as.Date("2019-01-04"), workdays(1)) [1] "2019-01-07" > > > > cleanEx() detaching ‘package:vctrs’ > nameEx("cal_events") > ### * cal_events > > flush(stderr()); flush(stdout()) > > ### Name: cal_events > ### Title: Calendar events > ### Aliases: cal_events > > ### ** Examples > > on_weekends <- weekly() %>% + recur_on_weekends() > > # New Year's Day, observed on the nearest weekday if it falls on a weekend > on_new_years <- hol_new_years_day() %>% + hol_observe(on_weekends, adj_nearest) > > # Christmas, observed on the nearest weekday if it falls on a weekend > on_christmas <- hol_christmas() %>% + hol_observe(on_weekends, adj_nearest) > > cal <- rcalendar(on_new_years, on_christmas) > cal • New Year's Day • Christmas > > # In 2010, Christmas fell on a Saturday and was adjusted backwards > cal_events(cal, year = 2010) name date 1 New Year's Day 2010-01-01 2 Christmas 2010-12-24 > > # In 2011, New Year's fell on a Saturday and was adjusted backwards. > # Note that the returned date is in 2010, even though we requested holidays > # for 2011, because most people would consider the actual New Year's date of > # 2011-01-01 part of the 2011 set of holidays, even though it was observed in > # 2010. > cal_events(cal, year = 2011) name date 1 New Year's Day 2010-12-31 2 Christmas 2011-12-26 > > # If you want to filter by the observed date, set `observed = TRUE`, which > # will move the New Year's Day that was observed in 2010 to the 2010 result > cal_events(cal, year = 2010, observed = TRUE) name date 1 New Year's Day 2010-01-01 2 Christmas 2010-12-24 3 New Year's Day 2010-12-31 > cal_events(cal, year = 2011, observed = TRUE) name date 1 Christmas 2011-12-26 > > > > cleanEx() > nameEx("cal_match") > ### * cal_match > > flush(stderr()); flush(stdout()) > > ### Name: cal_match > ### Title: Calendar matching > ### Aliases: cal_match > > ### ** Examples > > cal <- rcalendar( + hol_christmas(), + hol_halloween(), + hol_new_years_day(), + hol_us_presidents_day() + ) > > x <- as.Date(c( + "2019-01-02", + "2019-12-25", + "2018-02-19", + "2018-02-20", + "2020-10-31" + )) > > cal_match(x, cal) [1] NA "Christmas" "US Presidents' Day" [4] NA "Halloween" > > > > cleanEx() > nameEx("cal_names") > ### * cal_names > > flush(stderr()); flush(stdout()) > > ### Name: cal_names > ### Title: Calendar names > ### Aliases: cal_names > > ### ** Examples > > x <- rcalendar(hol_christmas(), hol_new_years_day()) > cal_names(x) [1] "Christmas" "New Year's Day" > > > > cleanEx() > nameEx("cal_us_federal") > ### * cal_us_federal > > flush(stderr()); flush(stdout()) > > ### Name: cal_us_federal > ### Title: US federal calendar > ### Aliases: cal_us_federal > > ### ** Examples > > cal <- cal_us_federal() > > # All 2023 holidays > cal_events(cal, year = 2023) name date 1 New Year's Day 2023-01-02 2 US Martin Luther King Jr. Day 2023-01-16 3 US Presidents' Day 2023-02-20 4 US Memorial Day 2023-05-29 5 US Juneteenth 2023-06-19 6 US Independence Day 2023-07-04 7 US Labor Day 2023-09-04 8 US Indigenous Peoples' Day 2023-10-09 9 US Veterans Day 2023-11-10 10 US Thanksgiving 2023-11-23 11 Christmas 2023-12-25 > > # Notice that for 2028, `cal_events()` knows that you probably want to > # treat New Year's Day as a 2028 holiday even though it will observed in > # 2027 (because it will be a Saturday and will be rolled back to being > # observed on Friday) > cal_events(cal, year = 2028) name date 1 New Year's Day 2027-12-31 2 US Martin Luther King Jr. Day 2028-01-17 3 US Presidents' Day 2028-02-21 4 US Memorial Day 2028-05-29 5 US Juneteenth 2028-06-19 6 US Independence Day 2028-07-04 7 US Labor Day 2028-09-04 8 US Indigenous Peoples' Day 2028-10-09 9 US Veterans Day 2028-11-10 10 US Thanksgiving 2028-11-23 11 Christmas 2028-12-25 > > # Were any of these dates on a holiday? > x <- as.Date(c( + "2023-11-10", + "2023-10-05", + "2023-06-19", + "2023-05-29", + "2023-05-28" + )) > > alma_in(x, cal) [1] TRUE FALSE TRUE TRUE FALSE > > # Which one? > cal_match(x, cal) [1] "US Veterans Day" NA "US Juneteenth" "US Memorial Day" [5] NA > > > > cleanEx() > nameEx("calendar-add-remove") > ### * calendar-add-remove > > flush(stderr()); flush(stdout()) > > ### Name: calendar-add-remove > ### Title: Calendar additions and removals > ### Aliases: calendar-add-remove cal_add cal_remove > > ### ** Examples > > cal <- rcalendar( + hol_christmas(), + hol_halloween(), + hol_new_years_day(), + hol_us_presidents_day() + ) > > # Can't forget Easter! > cal %>% + cal_add(hol_easter()) • Christmas • Halloween • New Year's Day • US Presidents' Day • Easter > > # Didn't actually need Halloween > cal %>% + cal_remove(hol_halloween()) • Christmas • New Year's Day • US Presidents' Day > > # Can remove by name or by object > cal %>% + cal_remove("Halloween") • Christmas • New Year's Day • US Presidents' Day > > > > cleanEx() > nameEx("calendar-locations") > ### * calendar-locations > > flush(stderr()); flush(stdout()) > > ### Name: calendar-locations > ### Title: Calendar locations > ### Aliases: calendar-locations cal_next cal_previous > > ### ** Examples > > x <- as.Date(c("2023-04-11", "2023-08-10", "2021-05-06")) > cal <- cal_us_federal() > > cal_next(x, cal) name date 1 US Memorial Day 2023-05-29 2 US Labor Day 2023-09-04 3 US Memorial Day 2021-05-31 > cal_previous(x, cal) name date 1 US Presidents' Day 2023-02-20 2 US Independence Day 2023-07-04 3 US Presidents' Day 2021-02-15 > > > > cleanEx() > nameEx("holiday-utilities") > ### * holiday-utilities > > flush(stderr()); flush(stdout()) > > ### Name: holiday-utilities > ### Title: Holiday utility functions > ### Aliases: holiday-utilities hol_observe hol_offset hol_rename > > ### ** Examples > > > on_weekends <- weekly() %>% + recur_on_weekends() > > # Christmas, adjusted to nearest Friday or Monday if it falls on a weekend > on_christmas <- hol_christmas() %>% + hol_observe(on_weekends, adj_nearest) > > # Boxing Day is the day after Christmas. > # If observed Christmas is a Friday, then observed Boxing Day should be Monday. > # If observed Christmas is a Monday, then observed Boxing Day should be Tuesday. > on_boxing_day <- on_christmas %>% + hol_offset(1) %>% + hol_observe(on_weekends, adj_following) %>% + hol_rename("Boxing Day") > > christmas_dates <- alma_events(on_christmas, year = 2010:2015) > boxing_day_dates <- alma_events(on_boxing_day, year = 2010:2015) > > data.frame( + christmas = christmas_dates, + boxing_day = boxing_day_dates, + christmas_weekday = lubridate::wday(christmas_dates, label = TRUE), + boxing_day_weekday = lubridate::wday(boxing_day_dates, label = TRUE) + ) christmas boxing_day christmas_weekday boxing_day_weekday 1 2010-12-24 2010-12-27 Fri Mon 2 2011-12-26 2011-12-27 Mon Tue 3 2012-12-25 2012-12-26 Tue Wed 4 2013-12-25 2013-12-26 Wed Thu 5 2014-12-25 2014-12-26 Thu Fri 6 2015-12-25 2015-12-28 Fri Mon > > > > cleanEx() > nameEx("holidays") > ### * holidays > > flush(stderr()); flush(stdout()) > > ### Name: holidays > ### Title: Holidays > ### Aliases: holidays hol_christmas hol_christmas_eve hol_easter > ### hol_good_friday hol_halloween hol_new_years_day hol_new_years_eve > ### hol_st_patricks_day hol_valentines_day hol_us_election_day > ### hol_us_fathers_day hol_us_independence_day > ### hol_us_indigenous_peoples_day hol_us_juneteenth hol_us_labor_day > ### hol_us_martin_luther_king_junior_day hol_us_memorial_day > ### hol_us_mothers_day hol_us_presidents_day hol_us_thanksgiving > ### hol_us_veterans_day > > ### ** Examples > > on_christmas <- hol_christmas() > on_christmas • frequency: yearly • range: [1900-01-01, 2100-01-01] • month of year: Dec • day of month: 25 > > # These are like any other rschedule object > alma_events(on_christmas, year = 2020:2025) [1] "2020-12-25" "2021-12-25" "2022-12-25" "2023-12-25" "2024-12-25" [6] "2025-12-25" > > # But they can also be added into an rcalendar > cal <- rcalendar( + on_christmas, + hol_halloween(), + hol_new_years_day(), + hol_us_presidents_day() + ) > cal • Christmas • Halloween • New Year's Day • US Presidents' Day > > # Which gives you access to a number of `cal_*()` functions > cal_events(cal, year = 2020:2022) name date 1 New Year's Day 2020-01-01 2 US Presidents' Day 2020-02-17 3 Halloween 2020-10-31 4 Christmas 2020-12-25 5 New Year's Day 2021-01-01 6 US Presidents' Day 2021-02-15 7 Halloween 2021-10-31 8 Christmas 2021-12-25 9 New Year's Day 2022-01-01 10 US Presidents' Day 2022-02-21 11 Halloween 2022-10-31 12 Christmas 2022-12-25 > > > > cleanEx() > nameEx("new_rschedule") > ### * new_rschedule > > flush(stderr()); flush(stdout()) > > ### Name: new_rschedule > ### Title: Create a new rschedule > ### Aliases: new_rschedule rschedule_events > > ### ** Examples > > events <- as.Date("1970-01-01") > > static <- new_rschedule( + events = events, + class = "static_rschedule" + ) > > # You have to register an `rschedule_events()` method first! > try(alma_events(static)) Error in rschedule_events(rschedule) : subclasses must provide their own `rschedule_events()` method. > > > > cleanEx() > nameEx("radjusted") > ### * radjusted > > flush(stderr()); flush(stdout()) > > ### Name: radjusted > ### Title: Create an adjusted rschedule > ### Aliases: radjusted > > ### ** Examples > > since <- "2000-01-01" > until <- "2010-01-01" > > on_christmas <- yearly(since = since, until = until) %>% + recur_on_month_of_year("Dec") %>% + recur_on_day_of_month(25) > > # All Christmas dates, with no adjustments > alma_events(on_christmas) [1] "2000-12-25" "2001-12-25" "2002-12-25" "2003-12-25" "2004-12-25" [6] "2005-12-25" "2006-12-25" "2007-12-25" "2008-12-25" "2009-12-25" > > on_weekends <- weekly(since = since, until = until) %>% + recur_on_weekends() > > # Now all Christmas dates that fell on a weekend are > # adjusted either forwards or backwards, depending on which > # non-event date was closer > on_adj_christmas <- radjusted(on_christmas, on_weekends, adj_nearest) > > alma_events(on_adj_christmas) [1] "2000-12-25" "2001-12-25" "2002-12-25" "2003-12-25" "2004-12-24" [6] "2005-12-26" "2006-12-25" "2007-12-25" "2008-12-25" "2009-12-25" > > > > cleanEx() > nameEx("rcalendar") > ### * rcalendar > > flush(stderr()); flush(stdout()) > > ### Name: rcalendar > ### Title: Create a recurring calendar > ### Aliases: rcalendar > > ### ** Examples > > on_earth_day <- yearly() %>% + recur_on_month_of_year("April") %>% + recur_on_day_of_month(22) %>% + rholiday("Earth Day") > > cal <- rcalendar( + hol_christmas(), + on_earth_day, + hol_us_independence_day() + ) > > cal • Christmas • Earth Day • US Independence Day > > cal_events(cal, year = 2020:2022) name date 1 Earth Day 2020-04-22 2 US Independence Day 2020-07-04 3 Christmas 2020-12-25 4 Earth Day 2021-04-22 5 US Independence Day 2021-07-04 6 Christmas 2021-12-25 7 Earth Day 2022-04-22 8 US Independence Day 2022-07-04 9 Christmas 2022-12-25 > > # Lookup holiday name based on date, if it exists > cal_match(c("2021-12-25", "2021-12-26"), cal) [1] "Christmas" NA > > # Find next holiday > alma_next("2021-12-26", cal) [1] "2022-04-22" > > > > cleanEx() > nameEx("rcustom") > ### * rcustom > > flush(stderr()); flush(stdout()) > > ### Name: rcustom > ### Title: Create a custom rschedule > ### Aliases: rcustom > > ### ** Examples > > include <- rcustom("2019-07-05") > exclude <- rcustom("2019-07-04") > > independence_day <- yearly() %>% + recur_on_month_of_year("July") %>% + recur_on_day_of_month(4) > > # Remove forcibly excluded day > independence_day <- rsetdiff(independence_day, exclude) > > # Add forcibly included day > independence_day <- runion(independence_day, include) > > alma_search("2018-01-01", "2020-12-31", independence_day) [1] "2018-07-04" "2019-07-05" "2020-07-04" > > > > cleanEx() > nameEx("recur_for_count") > ### * recur_for_count > > flush(stderr()); flush(stdout()) > > ### Name: recur_for_count > ### Title: Control the number of times to recur > ### Aliases: recur_for_count > > ### ** Examples > > # Using the default `since` date > daily_since_epoch_for_5 <- daily() %>% recur_for_count(5) > > alma_search("1969-12-31", "1970-01-25", daily_since_epoch_for_5) /usr/local/clang22me/bin/../include/c++/v1/__string/constexpr_c_functions.h:227:25: runtime error: store to misaligned address 0x000000000001 for type 'double *', which requires 8 byte alignment 0x000000000001: note: pointer points here #0 0x7f18bdad339a in double* std::__1::__constexpr_memmove[abi:nqe220108](double*, double const*, std::__1::__element_count) /usr/local/clang22me/bin/../include/c++/v1/__string/constexpr_c_functions.h:227:5 #1 0x7f18bdad339a in std::__1::pair std::__1::__copy_trivial_impl[abi:nqe220108](double const*, double const*, double*) /usr/local/clang22me/bin/../include/c++/v1/__algorithm/copy_move_common.h:64:3 #2 0x7f18bdad339a in std::__1::pair std::__1::__copy_impl::operator()[abi:nqe220108](double const*, double const*, double*) const /usr/local/clang22me/bin/../include/c++/v1/__algorithm/copy.h:115:12 #3 0x7f18bdad339a in std::__1::pair std::__1::__copy_move_unwrap_iters[abi:nqe220108](double const*, double const*, double*) /usr/local/clang22me/bin/../include/c++/v1/__algorithm/copy_move_common.h:94:19 #4 0x7f18bdad32bd in std::__1::pair std::__1::__copy[abi:nqe220108](double const*, double const*, double*) /usr/local/clang22me/bin/../include/c++/v1/__algorithm/copy.h:122:10 #5 0x7f18bdad32bd in double* std::__1::copy[abi:nqe220108](double const*, double const*, double*) /usr/local/clang22me/bin/../include/c++/v1/__algorithm/copy.h:128:10 #6 0x7f18bdad32bd in alma_search_impl(SEXPREC*, double, double, bool) /data/localhost/ripley/R/packages/tests-clang-UBSAN/almanac/src/alma-search.cc:27:3 #7 0x563398cdf585 in R_doDotCall (/data/localhost/ripley/R/R-clang/bin/exec/R+0x8f585) #8 0x563398d2b4b7 in bcEval_loop eval.c #9 0x563398d1983b in bcEval eval.c #10 0x563398d18ff4 in Rf_eval (/data/localhost/ripley/R/R-clang/bin/exec/R+0xc8ff4) #11 0x563398d31158 in R_execClosure eval.c #12 0x563398d3064a in applyClosure_core eval.c #13 0x563398d19f16 in Rf_applyClosure (/data/localhost/ripley/R/R-clang/bin/exec/R+0xc9f16) #14 0x563398d19447 in Rf_eval (/data/localhost/ripley/R/R-clang/bin/exec/R+0xc9447) #15 0x563398d66777 in Rf_ReplIteration (/data/localhost/ripley/R/R-clang/bin/exec/R+0x116777) #16 0x563398d6827e in run_Rmainloop (/data/localhost/ripley/R/R-clang/bin/exec/R+0x11827e) #17 0x563398d682ea in Rf_mainloop (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1182ea) #18 0x563398c51db7 in main (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1db7) #19 0x7f18c0f0b680 in __libc_start_call_main (/lib64/libc.so.6+0x3680) (BuildId: 17f2e1fd905f485786f6fd6e3bede4ad737137e7) #20 0x7f18c0f0b797 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3797) (BuildId: 17f2e1fd905f485786f6fd6e3bede4ad737137e7) #21 0x563398c51cd4 in _start (/data/localhost/ripley/R/R-clang/bin/exec/R+0x1cd4) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/local/clang22me/bin/../include/c++/v1/__string/constexpr_c_functions.h:227:25 Date of length 0 > > # Changing the `since` date > daily_since_2019_for_5 <- daily(since = "2019-01-01") %>% recur_for_count(5) > > alma_search("2018-12-31", "2019-01-25", daily_since_2019_for_5) [1] "2019-01-01" "2019-01-02" "2019-01-03" "2019-01-04" "2019-01-05" > > # In the case of "impossible" dates, such as 2019-02-31 and 2019-04-31 in the > # example below, they are not added to the total count. Only true event > # dates are counted. > on_31_for_5 <- monthly(since = "2019-01-01") %>% + recur_on_day_of_month(31) %>% + recur_for_count(5) > > alma_search("2019-01-01", "2020-01-01", on_31_for_5) [1] "2019-01-31" "2019-03-31" "2019-05-31" "2019-07-31" "2019-08-31" > > > > cleanEx() > nameEx("recur_on_day_of_month") > ### * recur_on_day_of_month > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_day_of_month > ### Title: Recur on a day of the month > ### Aliases: recur_on_day_of_month > > ### ** Examples > > # When used with a yearly or monthly frequency, `recur_on_day_of_month()` > # expands the number of days in the event set. > on_yearly <- yearly() > on_yearly_day_of_month_1_to_2 <- on_yearly %>% recur_on_day_of_month(1:2) > > start <- "1999-01-01" > end <- "2000-06-30" > > alma_search(start, end, on_yearly) [1] "1999-01-01" "2000-01-01" > alma_search(start, end, on_yearly_day_of_month_1_to_2) [1] "1999-01-01" "1999-01-02" "1999-02-01" "1999-02-02" "1999-03-01" [6] "1999-03-02" "1999-04-01" "1999-04-02" "1999-05-01" "1999-05-02" [11] "1999-06-01" "1999-06-02" "1999-07-01" "1999-07-02" "1999-08-01" [16] "1999-08-02" "1999-09-01" "1999-09-02" "1999-10-01" "1999-10-02" [21] "1999-11-01" "1999-11-02" "1999-12-01" "1999-12-02" "2000-01-01" [26] "2000-01-02" "2000-02-01" "2000-02-02" "2000-03-01" "2000-03-02" [31] "2000-04-01" "2000-04-02" "2000-05-01" "2000-05-02" "2000-06-01" [36] "2000-06-02" > > # When used with a daily frequency, `recur_on_day_of_month()` limits the > # number of days in the event set. > on_daily <- daily() > on_daily_day_of_month_1_to_2 <- on_daily %>% recur_on_day_of_month(1:2) > > length(alma_search(start, end, on_daily)) [1] 547 > length(alma_search(start, end, on_daily_day_of_month_1_to_2)) [1] 36 > > # Using a negative value is a powerful way to look back from the end of the > # month. This is particularly useful because months don't have the same > # number of days. > on_last_of_month <- monthly() %>% recur_on_day_of_month(-1) > > alma_search(start, end, on_last_of_month) [1] "1999-01-31" "1999-02-28" "1999-03-31" "1999-04-30" "1999-05-31" [6] "1999-06-30" "1999-07-31" "1999-08-31" "1999-09-30" "1999-10-31" [11] "1999-11-30" "1999-12-31" "2000-01-31" "2000-02-29" "2000-03-31" [16] "2000-04-30" "2000-05-31" "2000-06-30" > > # If you want particular days of the week at the end of the month, you > # could use something like this, which checks if the end of the month > # is also a Friday. > on_last_of_month_that_is_also_friday <- on_last_of_month %>% recur_on_day_of_week("Friday") > alma_search(start, end, on_last_of_month_that_is_also_friday) [1] "1999-04-30" "1999-12-31" "2000-03-31" "2000-06-30" > > # But you probably wanted this, which takes the last friday of the month, > # on whatever day that lands on > on_last_friday_of_month <- monthly() %>% recur_on_day_of_week("Friday", nth = -1) > alma_search(start, end, on_last_friday_of_month) [1] "1999-01-29" "1999-02-26" "1999-03-26" "1999-04-30" "1999-05-28" [6] "1999-06-25" "1999-07-30" "1999-08-27" "1999-09-24" "1999-10-29" [11] "1999-11-26" "1999-12-31" "2000-01-28" "2000-02-25" "2000-03-31" [16] "2000-04-28" "2000-05-26" "2000-06-30" > > > > cleanEx() > nameEx("recur_on_day_of_week") > ### * recur_on_day_of_week > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_day_of_week > ### Title: Recur on a day of the week > ### Aliases: recur_on_day_of_week recur_on_weekdays recur_on_weekends > > ### ** Examples > > # Using default `since` (1900-01-01, a Monday) > on_weekly_mondays <- weekly() > > start <- "1999-01-01" # <- a Friday > end <- "1999-03-01" > > # This finds the first Monday, and then continues from there > alma_search(start, end, on_weekly_mondays) [1] "1999-01-04" "1999-01-11" "1999-01-18" "1999-01-25" "1999-02-01" [6] "1999-02-08" "1999-02-15" "1999-02-22" "1999-03-01" > > # We start counting from a Friday here > on_weekly_fridays <- weekly(since = start) > alma_search(start, end, on_weekly_fridays) [1] "1999-01-01" "1999-01-08" "1999-01-15" "1999-01-22" "1999-01-29" [6] "1999-02-05" "1999-02-12" "1999-02-19" "1999-02-26" > > # Alternatively, we could use `recur_on_day_of_week()` and force a recurrence > # rule on Friday > on_forced_friday <- on_weekly_mondays %>% recur_on_day_of_week("Friday") > alma_search(start, end, on_forced_friday) [1] "1999-01-01" "1999-01-08" "1999-01-15" "1999-01-22" "1999-01-29" [6] "1999-02-05" "1999-02-12" "1999-02-19" "1999-02-26" > > # At monthly frequencies, you can use n-th values to look for particular > # week day events > on_first_friday_in_month <- monthly() %>% recur_on_day_of_week("Fri", nth = 1) > alma_search(start, end, on_first_friday_in_month) [1] "1999-01-01" "1999-02-05" > > # Negative values let you look from the back > on_last_friday_in_month <- monthly() %>% recur_on_day_of_week("Fri", nth = -1) > alma_search(start, end, on_last_friday_in_month) [1] "1999-01-29" "1999-02-26" > > # At yearly frequencies, this looks for the first sunday of the year > on_first_sunday_in_year <- yearly() %>% recur_on_day_of_week("Sunday", nth = 1) > alma_search(start, end, on_first_sunday_in_year) [1] "1999-01-03" > > # Last week day of the month > last_weekday_of_month <- monthly() %>% + # Last occurrence of each weekday in the month + recur_on_day_of_week(c("Mon", "Tue", "Wed", "Thu", "Fri"), nth = -1) %>% + # Now choose the last one of those in each month + recur_on_position(-1) > > alma_search(start, end, last_weekday_of_month) [1] "1999-01-29" "1999-02-26" > > > > > cleanEx() > nameEx("recur_on_day_of_year") > ### * recur_on_day_of_year > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_day_of_year > ### Title: Recur on a day of the year > ### Aliases: recur_on_day_of_year > > ### ** Examples > > library(lubridate, warn.conflicts = FALSE) > > on_5th_day_of_year <- yearly() %>% recur_on_day_of_year(5) > > alma_search("1999-01-01", "2000-12-31", on_5th_day_of_year) [1] "1999-01-05" "2000-01-05" > > # Notice that if you use a `since` date that has a day of the year > # after the specified one, it rolls to the next year > on_5th_day_of_year2 <- yearly(since = "1999-01-06") %>% recur_on_day_of_year(5) > alma_search("1999-01-01", "2000-12-31", on_5th_day_of_year2) [1] "2000-01-05" > > # Negative values select from the back, which is useful in leap years > leap_year(as.Date("2000-01-01")) [1] TRUE > > last_day_of_year <- yearly() %>% recur_on_day_of_year(-1) > last_day_of_year_bad <- yearly() %>% recur_on_day_of_year(365) > > alma_search("1999-01-01", "2000-12-31", last_day_of_year) [1] "1999-12-31" "2000-12-31" > alma_search("1999-01-01", "2000-12-31", last_day_of_year_bad) [1] "1999-12-31" "2000-12-30" > > > > > cleanEx() detaching ‘package:lubridate’ > nameEx("recur_on_easter") > ### * recur_on_easter > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_easter > ### Title: Recur on easter > ### Aliases: recur_on_easter > > ### ** Examples > > on_easter <- yearly() %>% recur_on_easter() > > # Rather than: > if (FALSE) { + on_easter_monday <- yearly() %>% recur_on_easter(1) + } > > # Please use: > on_easter_monday <- roffset(on_easter, 1) > > alma_search("1999-01-01", "2001-01-01", on_easter) [1] "1999-04-04" "2000-04-23" > > both <- runion(on_easter, on_easter_monday) > > alma_search("1999-01-01", "2001-01-01", both) [1] "1999-04-04" "1999-04-05" "2000-04-23" "2000-04-24" > > > > cleanEx() > nameEx("recur_on_interval") > ### * recur_on_interval > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_interval > ### Title: Recur on an interval > ### Aliases: recur_on_interval > > ### ** Examples > > # The default interval is 1 > on_monthly <- monthly(since = "1999-01-01") > > alma_search("1999-01-01", "1999-06-01", on_monthly) [1] "1999-01-01" "1999-02-01" "1999-03-01" "1999-04-01" "1999-05-01" [6] "1999-06-01" > > # Adjust to every other month > on_every_other_month <- on_monthly %>% recur_on_interval(2) > > alma_search("1999-01-01", "1999-06-01", on_every_other_month) [1] "1999-01-01" "1999-03-01" "1999-05-01" > > # Note that the frequency is limited to "every other month", but you > # can still have multiple events inside a single month > on_every_other_month_on_day_25_or_26 <- on_every_other_month %>% + recur_on_day_of_month(25:26) > > alma_search("1999-01-01", "1999-06-01", on_every_other_month_on_day_25_or_26) [1] "1999-01-25" "1999-01-26" "1999-03-25" "1999-03-26" "1999-05-25" [6] "1999-05-26" > > > > > cleanEx() > nameEx("recur_on_month_of_year") > ### * recur_on_month_of_year > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_month_of_year > ### Title: Recur on a month of the year > ### Aliases: recur_on_month_of_year > > ### ** Examples > > # There is a big difference between adding this rule to a `yearly()` > # or `monthly()` frequency, and a `daily()` frequency. > > # Limit from every day to every day in February > on_feb_daily <- daily() %>% recur_on_month_of_year("Feb") > > # Limit from 1 day per month to 1 day in February > on_feb_monthly <- monthly() %>% recur_on_month_of_year("Feb") > > start <- "1999-01-01" > end <- "2001-01-01" > > alma_search(start, end, on_feb_daily) [1] "1999-02-01" "1999-02-02" "1999-02-03" "1999-02-04" "1999-02-05" [6] "1999-02-06" "1999-02-07" "1999-02-08" "1999-02-09" "1999-02-10" [11] "1999-02-11" "1999-02-12" "1999-02-13" "1999-02-14" "1999-02-15" [16] "1999-02-16" "1999-02-17" "1999-02-18" "1999-02-19" "1999-02-20" [21] "1999-02-21" "1999-02-22" "1999-02-23" "1999-02-24" "1999-02-25" [26] "1999-02-26" "1999-02-27" "1999-02-28" "2000-02-01" "2000-02-02" [31] "2000-02-03" "2000-02-04" "2000-02-05" "2000-02-06" "2000-02-07" [36] "2000-02-08" "2000-02-09" "2000-02-10" "2000-02-11" "2000-02-12" [41] "2000-02-13" "2000-02-14" "2000-02-15" "2000-02-16" "2000-02-17" [46] "2000-02-18" "2000-02-19" "2000-02-20" "2000-02-21" "2000-02-22" [51] "2000-02-23" "2000-02-24" "2000-02-25" "2000-02-26" "2000-02-27" [56] "2000-02-28" "2000-02-29" > > alma_search(start, end, on_feb_monthly) [1] "1999-02-01" "2000-02-01" > > > > cleanEx() > nameEx("recur_on_position") > ### * recur_on_position > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_position > ### Title: Recur on a position within a frequency > ### Aliases: recur_on_position > > ### ** Examples > > library(lubridate, warn.conflicts = FALSE) > > start <- "1999-01-01" > end <- "1999-05-01" > > # You might want the last day of the month that is either a > # Sunday or a Monday, but you don't want to return both. > # This would return both: > on_last_monday_and_sunday <- monthly() %>% + recur_on_day_of_week(c("Monday", "Sunday"), nth = -1) > > alma_search(start, end, on_last_monday_and_sunday) [1] "1999-01-25" "1999-01-31" "1999-02-22" "1999-02-28" "1999-03-28" [6] "1999-03-29" "1999-04-25" "1999-04-26" > > # To return just the last one, you would select the last value in > # the set, which is computed on a per month basis > on_very_last_monday_or_sunday <- on_last_monday_and_sunday %>% + recur_on_position(-1) > > alma_search(start, end, on_very_last_monday_or_sunday) [1] "1999-01-31" "1999-02-28" "1999-03-29" "1999-04-26" > > wday(alma_search(start, end, on_very_last_monday_or_sunday), label = TRUE) [1] Sun Sun Mon Mon Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat > > > > > cleanEx() detaching ‘package:lubridate’ > nameEx("recur_on_week_of_year") > ### * recur_on_week_of_year > > flush(stderr()); flush(stdout()) > > ### Name: recur_on_week_of_year > ### Title: Recur on a week of the year > ### Aliases: recur_on_week_of_year > > ### ** Examples > > # Weekly rules are a bit tricky because they are implemented to comply > # with ISO-8601 standards, which require that the first week of the year > # is when there are at least 4 days in that year, and the week starts on > # the week day specified by `recur_with_week_start()` (Monday by default). > on_first_week <- yearly() %>% recur_on_week_of_year(1) > > # In 2017: > # - Look at dates 1-4 > # - 2017-01-02 is a Monday, so start the first week here > alma_search("2017-01-01", "2017-01-25", on_first_week) [1] "2017-01-02" "2017-01-03" "2017-01-04" "2017-01-05" "2017-01-06" [6] "2017-01-07" "2017-01-08" > > # In 2015: > # - Look at dates 1-4 > # - None of these are Monday, so the start of the week is > # in the previous year > # - Look at 2014 and find the last Monday, 2014-12-29. This is the start of > # the first week in 2015. > alma_search("2014-12-25", "2015-01-25", on_first_week) [1] "2014-12-29" "2014-12-30" "2014-12-31" "2015-01-01" "2015-01-02" [6] "2015-01-03" "2015-01-04" > > # Say we want the start of the week to be Sunday instead of Monday! > > # In 2015: > # - Look at dates 1-4 > # - 2015-01-04 is a Sunday, so start the first week here > on_first_week_sun <- yearly() %>% + recur_on_week_of_year(1) %>% + recur_with_week_start("Sunday") > > alma_search("2014-12-25", "2015-01-25", on_first_week_sun) [1] "2015-01-04" "2015-01-05" "2015-01-06" "2015-01-07" "2015-01-08" [6] "2015-01-09" "2015-01-10" > > > > cleanEx() > nameEx("recur_with_week_start") > ### * recur_with_week_start > > flush(stderr()); flush(stdout()) > > ### Name: recur_with_week_start > ### Title: Control the start of the week > ### Aliases: recur_with_week_start > > ### ** Examples > > # Weekly rules are a bit tricky because they are implemented to comply > # with ISO-8601 standards, which require that the first week of the year > # is when there are at least 4 days in that year, and the week starts on > # the week day specified by `recur_with_week_start()` (Monday by default). > on_first_week <- yearly() %>% recur_on_week_of_year(1) > > # In 2017: > # - Look at dates 1-4 > # - 2017-01-02 is a Monday, so start the first week here > alma_search("2017-01-01", "2017-01-25", on_first_week) [1] "2017-01-02" "2017-01-03" "2017-01-04" "2017-01-05" "2017-01-06" [6] "2017-01-07" "2017-01-08" > > # In 2015: > # - Look at dates 1-4 > # - None of these are Monday, so the start of the week is > # in the previous year > # - Look at 2014 and find the last Monday, 2014-12-29. This is the start of > # the first week in 2015. > alma_search("2014-12-25", "2015-01-25", on_first_week) [1] "2014-12-29" "2014-12-30" "2014-12-31" "2015-01-01" "2015-01-02" [6] "2015-01-03" "2015-01-04" > > # Say we want the start of the week to be Sunday instead of Monday! > > # In 2015: > # - Look at dates 1-4 > # - 2015-01-04 is a Sunday, so start the first week here > on_first_week_sun <- yearly() %>% + recur_on_week_of_year(1) %>% + recur_with_week_start("Sunday") > > alma_search("2014-12-25", "2015-01-25", on_first_week_sun) [1] "2015-01-04" "2015-01-05" "2015-01-06" "2015-01-07" "2015-01-08" [6] "2015-01-09" "2015-01-10" > > > > cleanEx() > nameEx("rholiday") > ### * rholiday > > flush(stderr()); flush(stdout()) > > ### Name: rholiday > ### Title: Create a recurring holiday > ### Aliases: rholiday > > ### ** Examples > > on_christmas <- yearly() %>% + recur_on_month_of_year("Dec") %>% + recur_on_day_of_month(25) > > # Bundle a holiday name with its recurrence schedule to create a holiday > rholiday(on_christmas, "Christmas") • frequency: yearly • range: [1900-01-01, 2100-01-01] • month of year: Dec • day of month: 25 > > # This is how the built in holiday objects are created > hol_christmas() • frequency: yearly • range: [1900-01-01, 2100-01-01] • month of year: Dec • day of month: 25 > > > > cleanEx() > nameEx("roffset") > ### * roffset > > flush(stderr()); flush(stdout()) > > ### Name: roffset > ### Title: Create an offset rschedule > ### Aliases: roffset > > ### ** Examples > > on_christmas <- yearly() %>% + recur_on_month_of_year("Dec") %>% + recur_on_day_of_month(25) > > on_day_after_christmas <- roffset(on_christmas, by = 1) > > alma_search("2018-01-01", "2023-01-01", on_day_after_christmas) [1] "2018-12-26" "2019-12-26" "2020-12-26" "2021-12-26" "2022-12-26" > > # Now what if you want the observed holiday representing the day after > # Christmas? > on_weekends <- weekly() %>% recur_on_weekends() > > # Adjust Christmas to the nearest weekday > on_christmas <- radjusted(on_christmas, on_weekends, adj_nearest) > > # Offset by 1 and then adjust that to the following weekday. > # We never adjust backwards because that can coincide with the observed day > # for Christmas. > on_day_after_christmas <- on_christmas %>% + roffset(by = 1) %>% + radjusted(on_weekends, adj_following) > > # Note that: > # - A Christmas on Friday the 24th resulted in a day after Christmas of > # Monday the 27th > # - A Christmas on Monday the 26th resulted in a day after Christmas of > # Tuesday the 27th > christmas <- alma_search("2018-01-01", "2023-01-01", on_christmas) > day_after_christmas <- alma_search("2018-01-01", "2023-01-01", on_day_after_christmas) > > lubridate::wday(christmas, label = TRUE) [1] Tue Wed Fri Fri Mon Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat > lubridate::wday(day_after_christmas, label = TRUE) [1] Wed Thu Mon Mon Tue Levels: Sun < Mon < Tue < Wed < Thu < Fri < Sat > > > > cleanEx() > nameEx("rrule") > ### * rrule > > flush(stderr()); flush(stdout()) > > ### Name: rrule > ### Title: Create a recurrence rule > ### Aliases: rrule daily weekly monthly yearly > > ### ** Examples > > rrule <- monthly() %>% recur_on_day_of_month(25) > > alma_search("1970-01-01", "1971-01-01", rrule) [1] "1970-01-25" "1970-02-25" "1970-03-25" "1970-04-25" "1970-05-25" [6] "1970-06-25" "1970-07-25" "1970-08-25" "1970-09-25" "1970-10-25" [11] "1970-11-25" "1970-12-25" > > # Notice that dates before 1900-01-01 are never generated with the defaults! > alma_search("1899-01-01", "1901-01-01", rrule) [1] "1900-01-25" "1900-02-25" "1900-03-25" "1900-04-25" "1900-05-25" [6] "1900-06-25" "1900-07-25" "1900-08-25" "1900-09-25" "1900-10-25" [11] "1900-11-25" "1900-12-25" > > # Adjust the `since` date to get access to these dates > rrule_pre_1900 <- monthly(since = "1850-01-01") %>% recur_on_day_of_month(25) > alma_search("1899-01-01", "1901-01-01", rrule_pre_1900) [1] "1899-01-25" "1899-02-25" "1899-03-25" "1899-04-25" "1899-05-25" [6] "1899-06-25" "1899-07-25" "1899-08-25" "1899-09-25" "1899-10-25" [11] "1899-11-25" "1899-12-25" "1900-01-25" "1900-02-25" "1900-03-25" [16] "1900-04-25" "1900-05-25" "1900-06-25" "1900-07-25" "1900-08-25" [21] "1900-09-25" "1900-10-25" "1900-11-25" "1900-12-25" > > # A quarterly recurrence rule can be built from > # `monthly()` and `recur_on_interval()` > on_first_of_the_quarter <- monthly() %>% + recur_on_interval(3) %>% + recur_on_day_of_month(1) > > alma_search("1999-01-01", "2000-04-01", on_first_of_the_quarter) [1] "1999-01-01" "1999-04-01" "1999-07-01" "1999-10-01" "2000-01-01" [6] "2000-04-01" > > # Alter the starting quarter by altering the `since` date > on_first_of_the_quarter_starting_in_feb <- monthly(since = "1998-02-01") %>% + recur_on_interval(3) %>% + recur_on_day_of_month(1) > > alma_search( + "1999-01-01", + "2000-04-01", + on_first_of_the_quarter_starting_in_feb + ) [1] "1999-02-01" "1999-05-01" "1999-08-01" "1999-11-01" "2000-02-01" > > > > > cleanEx() > nameEx("rset-add") > ### * rset-add > > flush(stderr()); flush(stdout()) > > ### Name: rset-add > ### Title: Deprecated rset helpers > ### Aliases: rset-add add_rschedule add_rdates add_exdates > ### Keywords: internal > > ### ** Examples > > on_thanksgiving <- yearly() %>% + recur_on_day_of_week("Thurs", nth = 4) %>% + recur_on_month_of_year("Nov") > > on_christmas <- yearly() %>% + recur_on_day_of_month(25) %>% + recur_on_month_of_year("Dec") > > on_labor_day <- monthly() %>% + recur_on_month_of_year("Sep") %>% + recur_on_day_of_week("Mon", nth = 1) > > # Rather than: > if (FALSE) { + rb <- runion() %>% + add_rschedule(on_thanksgiving) %>% + add_rschedule(on_christmas) %>% + add_rschedule(on_labor_day) + } > > # Use the `...` of the `runion()` helper directly: > rb <- runion(on_thanksgiving, on_christmas, on_labor_day) > > # Thanksgiving, Christmas, or Labor Day > alma_search("2019-01-01", "2021-01-01", rb) [1] "2019-09-02" "2019-11-28" "2019-12-25" "2020-09-07" "2020-11-26" [6] "2020-12-25" > > # Except Labor Day in 2019 > # Rather than: > if (FALSE) { + rb2 <- add_exdates(rb, "2019-09-02") + } > > # We recommend: > rb2 <- rsetdiff(rb, rcustom("2019-09-02")) > > alma_search("2019-01-01", "2021-01-01", rb2) [1] "2019-11-28" "2019-12-25" "2020-09-07" "2020-11-26" "2020-12-25" > > > > cleanEx() > nameEx("rset") > ### * rset > > flush(stderr()); flush(stdout()) > > ### Name: rset > ### Title: Create a new set-based recurrence schedule > ### Aliases: rset runion rintersect rsetdiff > > ### ** Examples > > since <- "2019-04-01" > until <- "2019-05-31" > > on_weekends <- weekly(since = since, until = until) %>% + recur_on_weekends() > > on_25th <- monthly(since = since, until = until) %>% + recur_on_day_of_month(25) > > # On weekends OR the 25th of the month > ru <- runion(on_weekends, on_25th) > alma_events(ru) [1] "2019-04-06" "2019-04-07" "2019-04-13" "2019-04-14" "2019-04-20" [6] "2019-04-21" "2019-04-25" "2019-04-27" "2019-04-28" "2019-05-04" [11] "2019-05-05" "2019-05-11" "2019-05-12" "2019-05-18" "2019-05-19" [16] "2019-05-25" "2019-05-26" > > # On weekends AND the 25th of the month > ri <- rintersect(on_weekends, on_25th) > alma_events(ri) [1] "2019-05-25" > > # On weekends AND NOT the 25th of the month > rsd1 <- rsetdiff(on_weekends, on_25th) > alma_events(rsd1) [1] "2019-04-06" "2019-04-07" "2019-04-13" "2019-04-14" "2019-04-20" [6] "2019-04-21" "2019-04-27" "2019-04-28" "2019-05-04" "2019-05-05" [11] "2019-05-11" "2019-05-12" "2019-05-18" "2019-05-19" "2019-05-26" > > # On the 25th of the month AND NOT the weekend > rsd2 <- rsetdiff(on_25th, on_weekends) > alma_events(rsd2) [1] "2019-04-25" > > > > cleanEx() > nameEx("stepper") > ### * stepper > > flush(stderr()); flush(stdout()) > > ### Name: stepper > ### Title: Create a new stepper > ### Aliases: stepper %s+% %s-% workdays > > ### ** Examples > > # A Thursday and Friday > x <- as.Date(c("1970-01-01", "1970-01-02")) > > # Thursday is stepped forward 1 working day to Friday, > # and then 1 more working day to Monday. > # Friday is stepped forward 1 working day to Monday, > # and then 1 more working day to Tuesday > x %s+% workdays(2) [1] "1970-01-05" "1970-01-06" > > # --------------------------------------------------------------------------- > > on_weekends <- weekly() %>% + recur_on_weekends() > > on_christmas <- yearly() %>% + recur_on_day_of_month(25) %>% + recur_on_month_of_year("Dec") > > rb <- runion(on_weekends, on_christmas) > > workday <- stepper(rb) > > # Friday before Christmas, which was on a Monday > friday_before_christmas <- as.Date("2000-12-22") > > # Steps over the weekend and Christmas to the following Tuesday > friday_before_christmas %s+% workday(1) [1] "2000-12-26" > > # --------------------------------------------------------------------------- > > # Christmas in 2005 was on a Sunday, but your company probably "observed" > # it on Monday. So when you are on the Friday before Christmas in 2005, > # stepping forward 1 working day should go to Tuesday. > > # We'll adjust the previous rule for Christmas to roll to the nearest > # non-weekend day, if it happened to fall on a weekend. > on_observed_christmas <- radjusted( + on_christmas, + adjust_on = on_weekends, + adjustment = adj_nearest + ) > > # Note that the "observed" date for Christmas is the 26th > alma_search("2005-01-01", "2006-01-01", on_observed_christmas) [1] "2005-12-26" > > rb2 <- runion(on_weekends, on_observed_christmas) > > workday2 <- stepper(rb2) > > friday_before_christmas_2005 <- as.Date("2005-12-23") > > # Steps over the weekend and the observed Christmas date > # of 2005-12-26 to Tuesday the 27th. > friday_before_christmas_2005 %s+% workday2(1) [1] "2005-12-27" > > > > ### *