inst/explorer/global/function_format_date.R

#' Print friendly English date
#'
#' @param date date vector of length 1
#'
#' @return string of format "Friday 12 April 2019", regardless of locale.
format_date <- function(date) {
  WEEKDAYS <- c(
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
  )
  weekday <- WEEKDAYS[lubridate::wday(date, week_start = 1)]
  day <- format(date, "%d")
  month <- month.name[as.integer(format(date, "%m"))]
  year <- format(date, "%Y")
  return(paste(
    weekday,
    day,
    month,
    year
  ))
}

Try the corporaexplorer package in your browser

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

corporaexplorer documentation built on June 20, 2022, 5:20 p.m.