output$text_calendar_range <- renderText({
req(input$calendar_dates)
year_start <- lubridate::year(input$calendar_dates$start)
month_start <- lubridate::month(input$calendar_dates$start)
date_start <- as.Date(input$calendar_dates$start)
year_end <- lubridate::year(input$calendar_dates$end)
month_end <- lubridate::month(input$calendar_dates$end)
date_end <- as.Date(input$calendar_dates$end)
if(month_start == month_end) {
return(
format(date_start, format = "%b %Y") |>
stringr::str_to_upper()
)
}
if(year_start == year_end) {
return(
paste0(
format(date_start, format = "%b"),
"/",
format(date_end, format = "%b %Y")
) |>
stringr::str_to_upper()
)
}
if(year_start != year_end) {
return(
paste0(
format(date_start, format = "%b %Y"),
"/",
format(date_end, format = "%b %Y")
) |>
stringr::str_to_upper()
)
}
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.