This package provides a `timeInput` widget for Shiny. This widget allows intuitive time input in the `[hh]:[mm]:[ss]` (24H) format by using a separate numeric input for each part of the time. Setting and getting of the time in R is done with 'DateTimeClasses' objects.
This package provides a `timeInput` widget for Shiny. This widget allows intuitive time input in the `[hh]:[mm]:[ss]`or `[hh]:[mm]`(24H) format by using a separate numeric input for each time component. Setting and getting of the time in R is done with 'DateTimeClasses' objects.
Usage
=====
@@ -18,17 +18,23 @@ As the `shinyTime` package mimics the existing shiny functionality, using the pa
# Set to current time
timeInput("time2", "Time:", value = Sys.time()),
# Set to custom time using
timeInput("time3", "Time:", value = strptime("12:34:56", "%T"))
# Set to custom time
timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
# Use %H:%M format
timeInput("time4", "Time:", seconds = FALSE)
)
Note that setting an inital value is done with a [`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses) class, in the same way as setting a date in `dateInput` can done with a `Date`class.
Note that setting an inital value is done with a [`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses) object, in the same way as setting a date in `dateInput` can be done with a `Date`object.
To retrieve the value, take note that the value will alse be in`DateTime`class. You need to convert it to character to be able to print the time, as the default character representation does not include the time. An example:
The value retrieved will also be a`DateTime`object. You need to convert it to character to be able to print the time, as the default character representation does not include it. An example:
server <- function(input, output) {
# Print the time in [hh]:[mm]:[ss] everytime it changes
observe(print(strftime(input$time1, "%T"))),
observe(print(strftime(input$time1, "%T")))
# Print the time in [hh]:[mm] everytime it changes
observe(print(strftime(input$time4, "%R")))
}
For a fully functional exampletry the `shinyTimeExample()` function in the package.
For a fully functional app go to the [ShinyApps example](https://burgerga.shinyapps.io/shinyTimeExample/) (can be a bit slow) or try the `shinyTime::shinyTimeExample()` function after installing the package with `install.packages('shinyTime')`.
Some generated files are not rendered by default. Learn more.
Oops, something went wrong.
No commit comments for this range
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
Some generated files are not rendered by default. Learn more.
Some generated files are not rendered by default. Learn more.
Some generated files are not rendered by default. Learn more.
Some generated files are not rendered by default. Learn more.