mirror of
https://github.com/rstudio/shiny.git
synced 2026-01-11 16:08:19 -05:00
Update dateYMD (#4318)
Co-authored-by: Garrick Aden-Buie <garrick@adenbuie.com>
This commit is contained in:
2
NEWS.md
2
NEWS.md
@@ -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)
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -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, "")
|
||||
|
||||
Reference in New Issue
Block a user