R/to_datetime.R

Defines functions to_datetime.character to_datetime.Date to_datetime

# Internal function to help ensure we convert dates correctly
# If we are given a Date object, promote it to a POSIXct object
# If we are given a POSIXt object, return it (identity)
# If we are given a character then try to promote it to a POSIXct object

to_datetime <- function(x) {
  UseMethod("to_datetime")
}

to_datetime.Date <- function(x) {
  as.POSIXct(x)
}

to_datetime.POSIXt <- identity


to_datetime.character <- function(x) {
  as.POSIXct(x)
}

Try the NHSRplotthedots package in your browser

Any scripts or data that you put into this service are public.

NHSRplotthedots documentation built on Nov. 4, 2021, 1:07 a.m.