Group 2: Exercise 3

The following module input provides a text control that lets you type a date in ISO8601 format (yyyy-mm-dd). Complete the module by providing a server function that uses output$error to display a message if the entered value is not a valid date. The module should return a Date object for valid dates. (Hint: use strptime(x, "%Y-%m-%d") to parse the string; it will return NA if the value isn’t a valid date.)

ymdDateUI <- function(id, label) {
  
  ns <- NS(id)
  label <- paste0(label, " (yyyy-mm-dd)")
  
  fluidRow(
    # User inputs a date
    textInput(ns("date"), label),
    
    # (OPTIONAL) User confirms the input date
    actionButton(ns("check"), "Confirm Date"),
    
    # Display error message if the date is invalid
    textOutput(ns("error"))
  )
}