在 Shiny 中,当我尝试airDatePickerInput
使用该updateAirDateInput
功能更新任何内容时,日期更新不正确。
如果我告诉updateAirDateInput
将日期设置为"2020-02-01"
,它会将日期设置为"2020-01-01"
,比我想要的少 1 天。为什么??
这是一个错误吗?我必须增加我想要的日期 + 1 吗?
这是一个显示我正在谈论的示例,按下按钮将日期设置为"1999-01-01"
,应用程序将错误地将日期设置为最后一天1998
library(shiny)
library(shinyWidgets)
shinyApp(
ui = fluidPage(
fluidRow(
column(
width = 12,
htmlOutput("someDate", inline = TRUE)
)
),
fluidRow(
column(
width = 12,
actionButton("b1", "Update Date")
)
)
),
server = function(input, output, session) {
#data$date <- format(as.Date(data$date, origin="1970-01-01"), "%m/%d/%Y")
output$someDate <- renderUI({
airDatepickerInput(
"someDate",
label = "Date",
value = NULL,
multiple = FALSE,
range = FALSE,
timepicker = FALSE,
separator = " - ",
placeholder = NULL,
dateFormat = "yyyy-mm-dd",
minDate = NULL,
maxDate = NULL,
disabledDates = NULL,
view = c("days", "months", "years"),
minView = c("days", "months", "years"),
monthsField = c("monthsShort", "months"),
clearButton = FALSE,
todayButton = FALSE,
autoClose = FALSE,
timepickerOpts = timepickerOptions(),
position = NULL,
update_on = c("change", "close"),
addon = c("right", "left", "none"),
language = "en",
inline = FALSE,
width = NULL
)
})
observeEvent(input$b1, {
updateAirDateInput(session, "someDate", value = as.character("1999-01-01"))
})
}
)