You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
884 B
R
28 lines
884 B
R
7 years ago
|
# parses from/to params for get_measurements_ and get_boxes_
|
||
7 years ago
|
parse_dateparams = function (from, to) {
|
||
|
from = utc_date(from)
|
||
|
to = utc_date(to)
|
||
7 years ago
|
if (from - to > 0) stop('"from" must be earlier than "to"')
|
||
7 years ago
|
c(date_as_isostring(from), date_as_isostring(to))
|
||
|
}
|
||
|
|
||
|
# NOTE: cannot handle mixed vectors of POSIXlt and POSIXct
|
||
|
utc_date = function (date) {
|
||
|
time = as.POSIXct(date)
|
||
|
attr(time, 'tzone') = 'UTC'
|
||
|
time
|
||
|
}
|
||
|
|
||
|
# NOTE: cannot handle mixed vectors of POSIXlt and POSIXct
|
||
7 years ago
|
date_as_isostring = function (date) format.Date(date, format = '%FT%TZ')
|
||
7 years ago
|
|
||
|
#' Simple factory function meant to implement dplyr functions for other classes,
|
||
|
#' which call an callback to attach the original class again after the fact.
|
||
|
#'
|
||
|
#' @param callback The function to call after the dplyr function
|
||
|
#' @noRd
|
||
|
dplyr_class_wrapper = function(callback) {
|
||
|
function(.data, ..., .dots) callback(NextMethod())
|
||
|
}
|
||
|
|