Update dateYMD (#4318)

Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
This commit is contained in:
ismirsehregal
2025-12-01 16:25:28 +01:00
committed by GitHub
parent 390f6d3b95
commit c8a41aa834
3 changed files with 11 additions and 1 deletions

View File

@@ -43,6 +43,8 @@
* Combinations of `bindEvent()` and `reactive()` / `observe()`
* Combination of `bindCache()` and `reactive()`
* `dateRangeInput()`/`updateDateRangeInput()` now correctly considers the time zones of date-time objects (POSIXct) passed to the `start`, `end`, `min` and `max` arguments. (thanks @ismirsehregal, #4318)
## Changes
* Markdown rendering in showcase mode now uses server-side rendering with the `{commonmark}` package, providing support for GitHub Flavored Markdown features (tables, strikethrough, autolinks, task lists). While most existing README.md files should continue to work as expected, some minor rendering differences may occur due to the change in markdown processor. (#4202, #4201)

View File

@@ -1433,7 +1433,11 @@ URLencode <- function(value, reserved = FALSE) {
dateYMD <- function(date = NULL, argName = "value") {
if (!length(date)) return(NULL)
tryCatch({
res <- format(as.Date(date), "%Y-%m-%d")
if (inherits(date, "POSIXt")) {
res <- format(date, "%Y-%m-%d")
} else {
res <- format(as.Date(date), "%Y-%m-%d")
}
if (any(is.na(res))) stop()
date <- res
},

View File

@@ -239,6 +239,10 @@ test_that("dateYMD works", {
dateYMD(c("2020/01/14", "2019/11/05")),
c("2020-01-14", "2019-11-05")
)
expect_identical(
dateYMD(as.POSIXct("2025-11-09 00:01:59", tz = "Asia/Tokyo")),
"2025-11-09"
)
expect_warning(val <- dateYMD(""))
expect_identical(val, "")