From cc2679e7fde8893f89c7f1869b43d2cc16f303c6 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 10 Apr 2023 11:38:31 -0400 Subject: [PATCH 1/3] New almanac_since/until() and don't override until --- NAMESPACE | 2 + R/defaults.R | 36 +++++++++++++ R/recur-for-count.R | 8 +-- R/recur-on-day-of-week.R | 5 +- R/rrule-print.R | 19 ++----- R/rrule.R | 22 +++++--- R/stepper.R | 2 +- README.md | 12 ++--- man/almanac-defaults.Rd | 33 ++++++++++++ man/recur_for_count.Rd | 5 +- man/recur_on_day_of_week.Rd | 5 +- man/rrule.Rd | 11 ++-- man/stepper.Rd | 2 +- tests/testthat/_snaps/radjusted.md | 12 ++--- tests/testthat/_snaps/rcustom.md | 3 +- tests/testthat/_snaps/recur-on-easter.md | 3 +- tests/testthat/_snaps/roffset.md | 9 ++-- tests/testthat/_snaps/rrule-print.md | 66 +++++++++--------------- tests/testthat/_snaps/rset.md | 18 +++---- tests/testthat/test-recur-for-count.R | 10 +++- vignettes/almanac.Rmd | 4 +- 21 files changed, 164 insertions(+), 123 deletions(-) create mode 100644 R/defaults.R create mode 100644 man/almanac-defaults.Rd diff --git a/NAMESPACE b/NAMESPACE index 2d90b34..47c641a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -47,6 +47,8 @@ export(alma_previous) export(alma_search) export(alma_seq) export(alma_step) +export(almanac_since) +export(almanac_until) export(daily) export(monthly) export(new_rschedule) diff --git a/R/defaults.R b/R/defaults.R new file mode 100644 index 0000000..ab3f3e2 --- /dev/null +++ b/R/defaults.R @@ -0,0 +1,36 @@ +#' Default values in almanac +#' +#' @description +#' - `almanac_since()` represents the default `since` date used in almanac. It +#' defaults to `1900-01-01`, a Monday. +#' +#' - `almanac_until()` represents the default `until` date used in almanac. It +#' defaults to `2100-01-01`, a Friday. +#' +#' The choice of `since` and `until` are somewhat arbitrary, but should generate +#' a useful event set range for most rschedules. If you need to adjust the +#' defaults, then you should supply the `since` and `until` arguments directly +#' to the rrule generators, like [yearly()] and [weekly()]. +#' +#' The `since` default is particularly important for weekly recurrence rules, +#' where the `since` date represents the anchor point to begin counting from. +#' See [recur_on_day_of_week()] for examples of how to adjust this. +#' +#' @name almanac-defaults +#' +#' @examples +#' almanac_since() +#' almanac_until() +NULL + +#' @export +#' @rdname almanac-defaults +almanac_since <- function() { + almanac_global_default_since +} + +#' @export +#' @rdname almanac-defaults +almanac_until <- function() { + almanac_global_default_until +} diff --git a/R/recur-for-count.R b/R/recur-for-count.R index 87c990e..485fc3a 100644 --- a/R/recur-for-count.R +++ b/R/recur-for-count.R @@ -2,11 +2,12 @@ #' #' @description #' `recur_for_count()` controls the total number of events in the recurrence -#' set. Using `recur_for_count()` will override the `until` date of the rule. +#' set. #' #' @details #' Remember that the number of times the occurrence has occurred is counted -#' from the `since` date! Adjust it as necessary to get your desired results. +#' from the `since` date and is limited by the `until` date! Adjust them as +#' necessary to get your desired results. #' #' @param x `[rrule]` #' @@ -46,6 +47,5 @@ recur_for_count <- function(x, n) { check_number_whole(n, min = 1) n <- vec_cast(n, to = integer()) - # Override `until` - tweak_rrule(x, until = NULL, count = n) + tweak_rrule(x, count = n) } diff --git a/R/recur-on-day-of-week.R b/R/recur-on-day-of-week.R index 62c9dee..92d6c83 100644 --- a/R/recur-on-day-of-week.R +++ b/R/recur-on-day-of-week.R @@ -15,7 +15,8 @@ #' #' It is particularly important to pay attention to the `since` date when using #' weekly rules. The day of the week to use comes from the `since` date, which, -#' by default, is a Monday (`1900-01-01`). +#' by default, is a Monday (`1900-01-01`). See [almanac_since()] for more +#' information. #' #' @inheritParams rlang::args_dots_empty #' @@ -45,7 +46,7 @@ #' start <- "1999-01-01" # <- a Friday #' end <- "1999-03-01" #' -#' # This finds the first Thursday, and then continues from there +#' # This finds the first Monday, and then continues from there #' alma_search(start, end, on_weekly_mondays) #' #' # We start counting from a Friday here diff --git a/R/rrule-print.R b/R/rrule-print.R index eb71280..33ff327 100644 --- a/R/rrule-print.R +++ b/R/rrule-print.R @@ -12,8 +12,7 @@ format_body <- function(x) { info <- c( format_frequency(x), - format_since(x), - format_until(x), + format_range(x), format_count(x), format_interval(x), format_week_start(x), @@ -33,19 +32,8 @@ format_frequency <- function(x) { cli::format_inline("frequency: {x$frequency}") } -format_since <- function(x) { - cli::format_inline("since: {x$since}") -} - -format_until <- function(x) { - until <- x$until - - if (is.null(until)) { - # Can be overriden when setting `count` - character() - } else { - cli::format_inline("until: {until}") - } +format_range <- function(x) { + cli::format_inline("range: [{x$since}, {x$until}]") } format_count <- function(x) { @@ -172,4 +160,5 @@ format_easter <- function(x) { } else { cli::format_inline("easter: offset = {easter}") } + } diff --git a/R/rrule.R b/R/rrule.R index 92a8830..11ddb29 100644 --- a/R/rrule.R +++ b/R/rrule.R @@ -16,7 +16,8 @@ #' @details #' By default, `since == "1900-01-01"` and `until == "2100-01-01"`, which should #' capture most use cases well while still being performant. You may need to -#' adjust these dates if you want events outside this range. +#' adjust these dates if you want events outside this range. See +#' [almanac_since()] and [almanac_until()] for more information. #' #' In terms of speed, it is generally more efficient if you adjust the `since` #' and `until` date to be closer to the first date in the sequence of dates @@ -83,25 +84,25 @@ NULL #' @rdname rrule #' @export -daily <- function(since = "1900-01-01", until = "2100-01-01") { +daily <- function(since = NULL, until = NULL) { rrule(since, until, frequency = "daily") } #' @rdname rrule #' @export -weekly <- function(since = "1900-01-01", until = "2100-01-01") { +weekly <- function(since = NULL, until = NULL) { rrule(since, until, frequency = "weekly") } #' @rdname rrule #' @export -monthly <- function(since = "1900-01-01", until = "2100-01-01") { +monthly <- function(since = NULL, until = NULL) { rrule(since, until, frequency = "monthly") } #' @rdname rrule #' @export -yearly <- function(since = "1900-01-01", until = "2100-01-01") { +yearly <- function(since = NULL, until = NULL) { rrule(since, until, frequency = "yearly") } @@ -115,6 +116,13 @@ rschedule_events.almanac_rrule <- function(x) { # ------------------------------------------------------------------------------ rrule <- function(since, until, frequency, ..., call = caller_env()) { + if (is_null(since)) { + since <- almanac_since() + } + if (is_null(until)) { + until <- almanac_until() + } + since <- vec_cast_date(since, call = call) vec_check_size(since, size = 1L, call = call) check_no_missing(since, call = call) @@ -138,8 +146,8 @@ rrule <- function(since, until, frequency, ..., call = caller_env()) { ) } -new_rrule <- function(since = as.Date("1900-01-01"), - until = as.Date("2100-01-01"), +new_rrule <- function(since = almanac_since(), + until = almanac_until(), frequency = "yearly", count = NULL, interval = NULL, diff --git a/R/stepper.R b/R/stepper.R index 0fb78dc..a99deb1 100644 --- a/R/stepper.R +++ b/R/stepper.R @@ -117,7 +117,7 @@ stepper <- function(rschedule) { #' @rdname stepper #' @export -workdays <- function(n, since = "1900-01-01", until = "2100-01-01") { +workdays <- function(n, since = NULL, until = NULL) { rschedule <- weekly(since = since, until = until) rschedule <- recur_on_weekends(rschedule) workdays_stepper <- stepper(rschedule) diff --git a/README.md b/README.md index fd9a6a5..8109ab1 100644 --- a/README.md +++ b/README.md @@ -48,8 +48,7 @@ on_thanksgiving <- yearly() %>% on_thanksgiving #> #> • frequency: yearly -#> • since: 1900-01-01 -#> • until: 2100-01-01 +#> • range: [1900-01-01, 2100-01-01] #> • month of year: Nov #> • day of week: Thu[4] ``` @@ -126,19 +125,16 @@ bundle #> #> #> • frequency: weekly -#> • since: 1900-01-01 -#> • until: 2100-01-01 +#> • range: [1900-01-01, 2100-01-01] #> • day of week: Sat, and Sun #> #> • frequency: yearly -#> • since: 1900-01-01 -#> • until: 2100-01-01 +#> • range: [1900-01-01, 2100-01-01] #> • month of year: Dec #> • day of month: 25 #> #> • frequency: yearly -#> • since: 1900-01-01 -#> • until: 2100-01-01 +#> • range: [1900-01-01, 2100-01-01] #> • month of year: Nov #> • day of week: Thu[4] ``` diff --git a/man/almanac-defaults.Rd b/man/almanac-defaults.Rd new file mode 100644 index 0000000..4fdc305 --- /dev/null +++ b/man/almanac-defaults.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/defaults.R +\name{almanac-defaults} +\alias{almanac-defaults} +\alias{almanac_since} +\alias{almanac_until} +\title{Default values in almanac} +\usage{ +almanac_since() + +almanac_until() +} +\description{ +\itemize{ +\item \code{almanac_since()} represents the default \code{since} date used in almanac. It +defaults to \code{1900-01-01}, a Monday. +\item \code{almanac_until()} represents the default \code{until} date used in almanac. It +defaults to \code{2100-01-01}, a Friday. +} + +The choice of \code{since} and \code{until} are somewhat arbitrary, but should generate +a useful event set range for most rschedules. If you need to adjust the +defaults, then you should supply the \code{since} and \code{until} arguments directly +to the rrule generators, like \code{\link[=yearly]{yearly()}} and \code{\link[=weekly]{weekly()}}. + +The \code{since} default is particularly important for weekly recurrence rules, +where the \code{since} date represents the anchor point to begin counting from. +See \code{\link[=recur_on_day_of_week]{recur_on_day_of_week()}} for examples of how to adjust this. +} +\examples{ +almanac_since() +almanac_until() +} diff --git a/man/recur_for_count.Rd b/man/recur_for_count.Rd index 0650587..94a2082 100644 --- a/man/recur_for_count.Rd +++ b/man/recur_for_count.Rd @@ -20,11 +20,12 @@ An updated rrule. } \description{ \code{recur_for_count()} controls the total number of events in the recurrence -set. Using \code{recur_for_count()} will override the \code{until} date of the rule. +set. } \details{ Remember that the number of times the occurrence has occurred is counted -from the \code{since} date! Adjust it as necessary to get your desired results. +from the \code{since} date and is limited by the \code{until} date! Adjust them as +necessary to get your desired results. } \examples{ # Using the default `since` date diff --git a/man/recur_on_day_of_week.Rd b/man/recur_on_day_of_week.Rd index 90dd050..b84f708 100644 --- a/man/recur_on_day_of_week.Rd +++ b/man/recur_on_day_of_week.Rd @@ -49,7 +49,8 @@ values. It is particularly important to pay attention to the \code{since} date when using weekly rules. The day of the week to use comes from the \code{since} date, which, -by default, is a Monday (\code{1900-01-01}). +by default, is a Monday (\code{1900-01-01}). See \code{\link[=almanac_since]{almanac_since()}} for more +information. } \examples{ # Using default `since` (1900-01-01, a Monday) @@ -58,7 +59,7 @@ on_weekly_mondays <- weekly() start <- "1999-01-01" # <- a Friday end <- "1999-03-01" -# This finds the first Thursday, and then continues from there +# This finds the first Monday, and then continues from there alma_search(start, end, on_weekly_mondays) # We start counting from a Friday here diff --git a/man/rrule.Rd b/man/rrule.Rd index 75bf566..2ca272b 100644 --- a/man/rrule.Rd +++ b/man/rrule.Rd @@ -8,13 +8,13 @@ \alias{yearly} \title{Create a recurrence rule} \usage{ -daily(since = "1900-01-01", until = "2100-01-01") +daily(since = NULL, until = NULL) -weekly(since = "1900-01-01", until = "2100-01-01") +weekly(since = NULL, until = NULL) -monthly(since = "1900-01-01", until = "2100-01-01") +monthly(since = NULL, until = NULL) -yearly(since = "1900-01-01", until = "2100-01-01") +yearly(since = NULL, until = NULL) } \arguments{ \item{since}{\verb{[Date(1)]} @@ -44,7 +44,8 @@ to them, use one of the \verb{recur_*()} functions. \details{ By default, \code{since == "1900-01-01"} and \code{until == "2100-01-01"}, which should capture most use cases well while still being performant. You may need to -adjust these dates if you want events outside this range. +adjust these dates if you want events outside this range. See +\code{\link[=almanac_since]{almanac_since()}} and \code{\link[=almanac_until]{almanac_until()}} for more information. In terms of speed, it is generally more efficient if you adjust the \code{since} and \code{until} date to be closer to the first date in the sequence of dates diff --git a/man/stepper.Rd b/man/stepper.Rd index 7cb394a..d3b7c60 100644 --- a/man/stepper.Rd +++ b/man/stepper.Rd @@ -13,7 +13,7 @@ x \%s+\% y x \%s-\% y -workdays(n, since = "1900-01-01", until = "2100-01-01") +workdays(n, since = NULL, until = NULL) } \arguments{ \item{rschedule}{\verb{[rschedule]} diff --git a/tests/testthat/_snaps/radjusted.md b/tests/testthat/_snaps/radjusted.md index ca0918f..bacf9f3 100644 --- a/tests/testthat/_snaps/radjusted.md +++ b/tests/testthat/_snaps/radjusted.md @@ -40,13 +40,11 @@ adjust: * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] adjust on: * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] Code # # with runions rrule <- recur_on_day_of_week(weekly(), "Wed") @@ -57,13 +55,11 @@ adjust: * frequency: weekly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of week: Wed adjust on: * frequency: weekly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] diff --git a/tests/testthat/_snaps/rcustom.md b/tests/testthat/_snaps/rcustom.md index 5d4c5a0..f2f0e4d 100644 --- a/tests/testthat/_snaps/rcustom.md +++ b/tests/testthat/_snaps/rcustom.md @@ -38,8 +38,7 @@ * and 95 more * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] # `events` can't be missing diff --git a/tests/testthat/_snaps/recur-on-easter.md b/tests/testthat/_snaps/recur-on-easter.md index ac36044..2881ebf 100644 --- a/tests/testthat/_snaps/recur-on-easter.md +++ b/tests/testthat/_snaps/recur-on-easter.md @@ -17,8 +17,7 @@ Message * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * easter: offset = 2 # offset must be integerish diff --git a/tests/testthat/_snaps/roffset.md b/tests/testthat/_snaps/roffset.md index 9e981a7..c05e601 100644 --- a/tests/testthat/_snaps/roffset.md +++ b/tests/testthat/_snaps/roffset.md @@ -6,8 +6,7 @@ * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] --- @@ -18,13 +17,11 @@ * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] # `by` must be a single integer diff --git a/tests/testthat/_snaps/rrule-print.md b/tests/testthat/_snaps/rrule-print.md index 4ee637f..91fa71d 100644 --- a/tests/testthat/_snaps/rrule-print.md +++ b/tests/testthat/_snaps/rrule-print.md @@ -6,22 +6,20 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] Code yearly() Message * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] Code # # until is overriden by recur_for_count() recur_for_count(daily(), 5) Message * frequency: daily - * since: 1900-01-01 + * range: [1900-01-01, 2100-01-01] * count: 5 Code # # can add multiple conditions @@ -29,7 +27,7 @@ Message * frequency: yearly - * since: 1900-01-01 + * range: [1900-01-01, 2100-01-01] * count: 5 * interval: 2 Code @@ -38,8 +36,7 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * month of year: Feb and Mar Code # # can use multiple weeks of the year @@ -47,8 +44,7 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * week of year: 5, 9, and 12 Code # # can use multiple days of the year @@ -56,8 +52,7 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of year: 5, 9, and 12 Code # # can use multiple days of the month @@ -65,8 +60,7 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of month: 5, 9, and 12 Code # # can use day of week variations @@ -74,8 +68,7 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of week: Mon[1, 2], and Thu[1, 2] Code recur_on_day_of_week(recur_on_day_of_week(daily(), "Mon", nth = c(1, 2)), "Thu", @@ -83,16 +76,14 @@ Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of week: Mon[1, 2], and Thu[4, 5] Code recur_on_day_of_week(yearly(), "Mon", nth = c(1, 2, 10, 13, 15, 16)) Message * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of week: Mon[1, 2, 10, 13, 15, 16] Code # # can use multiple positions @@ -100,16 +91,14 @@ Message * frequency: weekly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * position: -2, -1, 2, and 3 Code recur_on_position(yearly(), c(-1, 2, 3, -2, 10, 12, 13)) Message * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * position: -2, -1, 2, 3, 10, 12, and 13 Code # # each recur_ condition works @@ -117,78 +106,69 @@ Message * frequency: daily - * since: 1900-01-01 + * range: [1900-01-01, 2100-01-01] * count: 5 Code recur_on_interval(daily(), 5) Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * interval: 5 Code recur_with_week_start(daily(), "Tuesday") Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * week start: Tue Code recur_on_month_of_year(daily(), "Feb") Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * month of year: Feb Code recur_on_week_of_year(daily(), 5) Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * week of year: 5 Code recur_on_day_of_year(daily(), 5) Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of year: 5 Code recur_on_day_of_month(daily(), 5) Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of month: 5 Code recur_on_day_of_week(daily(), "Wed") Message * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * day of week: Wed Code recur_on_position(weekly(), 5) Message * frequency: weekly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * position: 5 Code recur_on_easter(weekly()) Message * frequency: weekly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * easter diff --git a/tests/testthat/_snaps/rset.md b/tests/testthat/_snaps/rset.md index 791c29c..b31503c 100644 --- a/tests/testthat/_snaps/rset.md +++ b/tests/testthat/_snaps/rset.md @@ -119,12 +119,10 @@ * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] # rintersect() generates informative output @@ -140,12 +138,10 @@ * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] # rsetdiff() generates informative output @@ -161,10 +157,8 @@ * frequency: daily - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] * frequency: yearly - * since: 1900-01-01 - * until: 2100-01-01 + * range: [1900-01-01, 2100-01-01] diff --git a/tests/testthat/test-recur-for-count.R b/tests/testthat/test-recur-for-count.R index 7c61aa1..4a58e7a 100644 --- a/tests/testthat/test-recur-for-count.R +++ b/tests/testthat/test-recur-for-count.R @@ -10,10 +10,18 @@ test_that("events stop after `count` is up", { expect_equal(x, expect) }) -test_that("`count` overrides `until`", { +test_that("`count` is limited by `until`", { rrule <- daily(since = "1970-01-01", until = "1970-01-02") %>% recur_for_count(3) + expect_identical( + alma_search("1970-01-01", "1970-01-05", rrule), + new_date(c(0, 1)) + ) + + rrule <- daily(since = "1970-01-01", until = "1970-01-03") %>% + recur_for_count(3) + expect_identical( alma_search("1970-01-01", "1970-01-05", rrule), new_date(c(0, 1, 2)) diff --git a/vignettes/almanac.Rmd b/vignettes/almanac.Rmd index ff0442d..7139a0e 100644 --- a/vignettes/almanac.Rmd +++ b/vignettes/almanac.Rmd @@ -51,7 +51,7 @@ alma_search(from = "1990-01-01", to = "1995-12-31", on_yearly) What if we want a yearly value, but we want it on January 5th every year, rather than on the 1st? `yearly()` has an important argument called `since` that controls two things: the start date of the recurrence rule, and information such as the month, or the day of the month to use if no other conditions have been specified to override those. -The default of `since` is set to `1900-01-01`, but this is arbitrary. It is because of this default that in the above example with `alma_search()` we get values on January 1st. Let's change that. +The default of `since` is set to `1900-01-01`, but this is arbitrary (see `almanac_since()`). It is because of this default that in the above example with `alma_search()` we get values on January 1st. Let's change that. ```{r} on_yearly_jan_5 <- yearly(since = "1990-01-05") @@ -66,7 +66,7 @@ Now that the `since` date has been set to 1990, if we try and find yearly dates alma_search("1988-01-01", "1995-12-31", on_yearly_jan_5) ``` -There is also an `until` argument to `yearly()` that controls the upper bound of the range to look in. This is arbitrarily set to `2100-01-01`, but can be expanded or contracted as required. +There is also an `until` argument to `yearly()` that controls the upper bound of the range to look in. This is arbitrarily set to `2100-01-01`, but can be expanded or contracted as required (see `almanac_until()`). ## Event Set From 65e45849f4f7b2e3e6596ba3068ad32f8a1bfb0e Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 10 Apr 2023 11:39:17 -0400 Subject: [PATCH 2/3] NEWS bullets --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 9279a82..ba76b98 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ # almanac (development version) +* `recur_for_count()` no longer overrides `until` (#95). + +* New `almanac_since()` and `almanac_until()` helpers to access the default + `since` and `until` values used for all rules (#95). + * `alma_events()` has gained a `year` argument to limit the returned set of events to specific years. From 67178991a04405863bb55b7c13809eb350193e50 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 10 Apr 2023 11:50:42 -0400 Subject: [PATCH 3/3] Add pkgdown entry --- _pkgdown.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_pkgdown.yml b/_pkgdown.yml index 1dcf0f2..1aaae53 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -37,6 +37,7 @@ reference: - title: Developer tools contents: - new_rschedule + - starts_with("almanac_") - title: Compatibility contents: