@@ -29,10 +29,28 @@ silence_warning <- function(expr, warning_message) {
2929
3030merge_with_no_duplicate_cols <- function (a , b , by ) merge(a , b [c(by , setdiff(names(b ), names(a )))], by )
3131
32- robust_min <- function (... ) min(... , + Inf , na.rm = TRUE ) # TODO: Remove if unused
33- robust_max <- function (... ) max(... , - Inf , na.rm = TRUE ) # TODO: Remove if unused
34-
32+ # ' Convert possibly truncated character(n) 'yyyy-mm-dd' to Date(n)
33+ # ' performing optional round up using the level of precision present
34+ # ' in the input data
35+ # '
36+ # ' @param data [character(n)] Vector of dates
37+ # '
38+ # ' @keywords internal
39+ # '
3540robust_ymd <- function (data , round_up = FALSE ) {
41+ # NOTE(miguel):
42+ # `dv.papo` used to rely on `lubridate` for date parsing.
43+ # We dropped that library because we didn't need any of its many advanced features.
44+ # Instead, we wrote this function to parse the only format we cared about ('yyyy-mm-dd'),
45+ # and to round end-dates up taking into account the unit information implicit to possibly
46+ # truncated ('yyyy', 'yyyy-mm') input strings.
47+ # Using `lubridate::ceiling_date` instead results in even more code on our part, since
48+ # that call assumes that all input dates have a homogeneous precision, which is not the case
49+ # for us.
50+ #
51+ # In any case, the point is moot because we now require users of `dv.papo` to provide Date
52+ # objects and this function is a (non-exported) helper to deal with character dates.
53+
3654 label <- attr(data , " label" )
3755
3856 data <- substr(data , 1 , 10 )
0 commit comments