#' @param data Reference dataset, object output of \code{getData}
#' @param limit Maximum number of indices to return
#' @param same_season Should the indices correspond to day in same season?
+#' @param days_in Optional set to intersect with results (NULL to discard)
#'
#' @export
-getSimilarDaysIndices = function(index, data, limit, same_season)
+getSimilarDaysIndices = function(index, data, limit, same_season, days_in=NULL)
{
index = dateIndexToInteger(index, data)
while (i >= 1 && length(days) < limit)
{
dt = as.POSIXlt(data$getTime(i)[1])
- if (.isSameDay(dt$wday, day_ref))
+ if ((is.null(days_in) || i %in% days_in) && .isSameDay(dt$wday, day_ref))
{
if (!same_season || .isSameSeason(dt$mon+1, month_ref))
days = c(days, i)