#' @title timetag
#'
#' @description Append a time tag to a file name. The time tag counts every
#' seconds since 2020-01-01 00:00. If the file has an extension, the suffix is
#' added before it. This allows to write backup files for example.
#'
#' @param file string
#'
#' @examples
#' timetag()
#' timetag("panel.xlsx")
#'
#' @export
timetag <- function(
file
) {
tag <- sprintf("%08X", as.integer(Sys.time()) -
as.integer(as.POSIXct("2020-01-01 00:00")))
if (missing(file)) return(tag)
if (grepl("\\..{1,5}$", file)) {
gsub("(.+)(\\..{1,5}$)", paste0("\\1-", tag, "\\2"), file)
} else {
paste0(file, "-", tag)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.