Skip to content

Commit

Permalink
check dates in season history
Browse files Browse the repository at this point in the history
  • Loading branch information
cturbelin committed Dec 5, 2018
1 parent 6af067b commit c55aad1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion R/platform.R
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,26 @@ platform_season_history <- function(season, dates, ...) {
}
def = list(...)
def$dates = dates

check_date = function(v, after=NULL) {
if(is.na(v)) {
return()
}
d = as.Date(v)
if(is.na(d)) {
stop(paste0(deparse(substitute(v)), "Unable to parse date '", v,"'"))
}
if(!is.null(after) ) {
after = as.Date(after)
if(d < after) {
stop(paste(deparse(substitute(v)), "should be after", after))
}
}
}

check_date(dates$start)
check_date(dates$end, after=dates$start)

.Share$historical.tables[[as.character(season)]] <- def
}

Expand Down Expand Up @@ -515,4 +535,4 @@ platform_options = function(...) {
#' @export
platform_env <- function() {
.Share
}
}

0 comments on commit c55aad1

Please sign in to comment.