From d7085df94c94cd1cc08635f7f0c6feaad11fe2bf Mon Sep 17 00:00:00 2001 From: Jennifer Thom Date: Thu, 12 Dec 2024 12:37:01 +0000 Subject: [PATCH] Automate `latest_update()` --- R/00-update_refs.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/R/00-update_refs.R b/R/00-update_refs.R index 7ff216c92..ab1b4f981 100644 --- a/R/00-update_refs.R +++ b/R/00-update_refs.R @@ -29,7 +29,9 @@ end_date <- function() { # Q2 September = 30092024 # Q3 December = 31122024 # Q4 March = 31032024 - lubridate::dmy(31122024) + end_date <- lubridate::dmy(31122024) + + return(end_date) } @@ -113,7 +115,14 @@ get_dd_period <- function() { #' #' @family initialisation latest_update <- function() { - "Dec_2024" + + end_date <- end_date() + month <- as.character(lubridate::month(end_date, label = TRUE)) + year <- as.character(lubridate::year(end_date)) + latest_update <- as.character(stringr::str_glue('{month}_{year}')) + + return(latest_update) + }