Sys.Date () shows wrong date in brilliant applications

This code should show me yesterday as the start and end date today as the last option. It worked for several months, I did not change anything, but from some weeks I get the wrong date.

This shows me the day before yesterday if I run this code locally, rstudio on my ubuntu server, or connect to a brilliant server that runs this code.

Sys.setenv(TZ='GMT')

shinyApp(
  ui <- basicPage(
    dateRangeInput("daterange", "Daterange",start = Sys.Date()-1
                   ,end = Sys.Date()-1,max=Sys.Date())
  ),
  server <- function(input,output){}
)

I found this question, In Shiny for R, why does Sys.Date () return yesterday's date inside dateInput? and with start = NULL, end = NULL I understood correctly today, but since I need yesterday, this is not a solution for me.

If I ran Sys.Date () in the console, it gave me the correct date, locally and on my server. The problem only occurs if I run it as a brilliant application.


Update 10.21.2015

I tried to get around a bit thanks to Oscar Forsmo's suggestion to get a system ("date") inside the application that gives me the correct date and time.

And it gets even weirder:

library(shiny)

values <- reactiveValues()

shinyApp(
  ui <- basicPage(
    uiOutput("timerange"),
    textOutput( "today" )

  ),
  server <- function(input,output){

    isolate(values$day <- Sys.Date())

    output$today <- renderText({
      as.character(values$day-1)
    })

   output$timerange <- renderUI({ dateRangeInput("daterange", "Daterange",start = values$day-1
                   ,end = values$day-1,max=values$day) })

  })

In the output object "today" I have the correct date, in the uiOutput timer "I have the wrong day, it shows again the day before yesterday."

I am going to provide a screenshot because I did not believe myself.

wrong day in dateRangeInput, right in textOutput

And besides, an application running on a brilliant server shows the correct time / date for some of my colleagues, and some get the same wrong date.

, renderText, - dateRangeInput, ?!


29.10.2015

/, , , , . - , , .

+4
1

, , . , POSIX ( ). , , Sys.Date(), format.

:

dateRangeInput("daterange", "Daterange", start = as.POSIXct(Sys.Date()-1),
              end = as.POSIXct(Sys.Date()-1), max = as.POSIXct(Sys.Date())),
              format = 'yyyy-mm-dd')
0

Source: https://habr.com/ru/post/1612427/


All Articles