R/package_datetime.R

Defines functions package_description_mtime package_datetime

#' Package datetimes
#'
#' Determine the datetimes for packages by checking the `DESCRIPTION` file
#' modification time.
#'
#' @param package A character vector containing the names of packages
#'
#' @return A `POSIXct` vector with names corresponding to `package`
#' @noRd
#' @keywords internal
#'
#' @examples
#'
#' package_datetime(c("utils", "makepipe"))
package_datetime <- function(package) {
  stopifnot_class(package, "character")
  out <- vapply(
    package,
    function(pkg) as.numeric(package_description_mtime(pkg)),
    FUN.VALUE = numeric(1)
  )

  as.POSIXct(out, origin = "1970-01-01")
}

package_description_mtime <- function(package) {
  stopifnot_class(package, "character")
  desc_loc <- paste0(find.package(package), "/DESCRIPTION")
  file.mtime(desc_loc)
}

Try the makepipe package in your browser

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

makepipe documentation built on Dec. 7, 2022, 5:16 p.m.