闪亮:为什么 lubridate::today() 函数突然开始返回生产部署中的过去日期?
Shiny: Why did the lubridate::today() function suddenly start returning a past date in a production deployment?
我们使用 today() 函数在闪亮的仪表板中设置日期选择输入的上限。
dateRangeInput(inputId = ns("transactionDateRange"),
label = "Date Range",
max = today(),
start = today() - 28,
end = today())
),
今天(星期一)我在我们的生产环境中打开 RStudio connect 中的仪表板,上限(“最大”)设置为上周四的日期。 “开始”参数也在上周四前 28 天返回。为什么前一天还没有问题的今天会发生这种情况?
多么奇怪的行为...lubridate::today()
function does nothing special but calls Sys.time()
from base R and formats it as date in the specified timezone. See the current source code。
而 Sys.time()
的 documentation 说:
Sys.time and Sys.Date returns the system's idea of the current date with and without time.
所以我认为首先您的生产环境的日期和时间可能存在一些问题。尝试在终端或 R 控制台中检查。
(我认为日期和时间不太可能被缓存。)
其他可能的情况:
- 您的浏览器会记住输入中的最后一个选择 - 尝试从另一台计算机打开您的应用程序,
- 该应用程序可以有意节省一些 cookies/settings(但我认为 Shiny 默认情况下不应这样做,因此请检查您的应用程序代码或从另一台计算机上尝试)。
我们使用 today() 函数在闪亮的仪表板中设置日期选择输入的上限。
dateRangeInput(inputId = ns("transactionDateRange"),
label = "Date Range",
max = today(),
start = today() - 28,
end = today())
),
今天(星期一)我在我们的生产环境中打开 RStudio connect 中的仪表板,上限(“最大”)设置为上周四的日期。 “开始”参数也在上周四前 28 天返回。为什么前一天还没有问题的今天会发生这种情况?
多么奇怪的行为...lubridate::today()
function does nothing special but calls Sys.time()
from base R and formats it as date in the specified timezone. See the current source code。
而 Sys.time()
的 documentation 说:
Sys.time and Sys.Date returns the system's idea of the current date with and without time.
所以我认为首先您的生产环境的日期和时间可能存在一些问题。尝试在终端或 R 控制台中检查。
(我认为日期和时间不太可能被缓存。)
其他可能的情况:
- 您的浏览器会记住输入中的最后一个选择 - 尝试从另一台计算机打开您的应用程序,
- 该应用程序可以有意节省一些 cookies/settings(但我认为 Shiny 默认情况下不应这样做,因此请检查您的应用程序代码或从另一台计算机上尝试)。