#' Parse Schedule Time
#'
#' Parse airport scheduled times into hh:mm format
#' @param sched_time vector of times in static format
#' @param date desired schedule date. Defaults to Sys.Date()
#' @keywords time
#' @export
#' @examples
#' x <- c(730, 1410, 5, 2315)
#' parse_sched_time(x)
parse_sched_time <- function(sched_time, date = Sys.Date()) {
# normalize times to 4 characters
return <- stringi::stri_pad_left(sched_time, 4, pad = "0")
# build up time and convert to POSIXct
return <- paste(stringi::stri_sub(return,1,2), stringi::stri_sub(return, 3, 4), sep=":")
return <- paste(date, return)
return <- lubridate::ymd_hm(return)
return(return)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.