Skip to content

Commit

Permalink
chore: add warnings [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Mar 21, 2024
1 parent cd7f00a commit d76bfe6
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions R/functions__eager.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,40 @@ pl_date_range = function(
closed = "both",
time_unit = NULL,
time_zone = NULL) {
.warn_for_deprecated_date_range_use(start, end, interval, time_unit, time_zone)

date_range(start, end, interval, closed, time_unit, time_zone) |>
unwrap("in pl$date_range():")
}


.warn_for_deprecated_date_range_use = function(
start,
end,
interval,
time_unit = NULL,
time_zone = NULL) {
if (
inherits(start, "difftime") ||
inherits(end, "difftime") ||
!is.null(time_unit) ||
!is.null(time_zone) ||
(
is.character(interval) &&
length(interval) == 1L &&
(grepl("h", interval) || grepl("m", gsub("mo", "", interval)) || grepl("s", gsub("saturating", "", interval)))
)
) {
warning(
"Creating Datetime ranges using `pl$date_range()` is deprecated.",
"Use `pl$datetime_range()` instead."
)
}

invisible(NULL)
}


#' Generate a datetime range
#' @inheritParams pl_date_range
#' @inheritSection pl_date_range Interval
Expand Down

0 comments on commit d76bfe6

Please sign in to comment.