diff --git a/R/formatAermodDate.R b/R/formatAermodDate.R new file mode 100644 index 0000000..9e5d681 --- /dev/null +++ b/R/formatAermodDate.R @@ -0,0 +1,20 @@ + +#' @title formatAermodDate +#' @description Take datetime format and change to Aeromod's fixed with year month day hour format used in .EMI files +#' @param d POSIXct. E.g. lubridate::ymd_hms("2011-05-01 04:00:00", tz = "Africa/Johannesburg") +#' @import lubridate + +formatAermodDate <- function(d){ + + space = " " + + if (!lubridate::is.POSIXct(d)) stop("d must be POSIXct") + paste0(fw(format(d, "%y"), 3, after = TRUE), + fw(lubridate::month(d), 2, after = FALSE), + space, + fw(format(d, "%e"), 2, after = FALSE), + space, + fw(lubridate::hour(d), 2, after = FALSE), + space + ) +}