#' Calculates serial dates using the same origin (0000-01-01) as MatLab.
#' @export
#' @title Calculate serial date
#' @param YY a numeric vector containing the 4-digit year.
#' @param MM a numeric vector containing the month of the year (e.g. 3 = March, 12 = December).
#' @param DD a numeric vector (1-31) containing the day of the month.
#' @param HH a numeric vector (0-23) containing the hour in a 24-hr clock (e.g. 0 = 12 am, 23 = 11 pm).
#' @param MIN a numeric vector (0-59) containing the minute in a 60-min hour.
#' @param SEC a numeric vector (0-59) containing the second in a 60-sec minute
fDatenum <- function(YY, MM, DD, HH, MIN, SEC) {
local <- lubridate::make_datetime(YY,MM,DD,HH,MIN)
date.int <- as.numeric(as.Date(paste(YY, MM, DD, HH, MIN, 0, sep = "-"))) + 719529 # calculates serial date as an integer
dec.hr = HH + MIN/60 # calculates hour and day as double floating number
dec.day = dec.hr/24
datetime.num = date.int + dec.day # adds the double floating number to the serial date integer (provides serial date with time as decimals)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.