R/parse_STA_STD.R

Defines functions parse_sched_time

Documented in parse_sched_time

#' 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)
}
lingwhatics/daleym documentation built on May 21, 2019, 6:16 a.m.