Skip to content

Commit 7148d36

Browse files
committed
Update README
1 parent 313a5d5 commit 7148d36

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

README.Rmd

+22-11
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ knitr::opts_chunk$set(
1313
)
1414
```
1515

16-
![](http://www.r-pkg.org/badges/version/shinyTime) ![](http://cranlogs.r-pkg.org/badges/grand-total/shinyTime) [![Build Status](https://travis-ci.org/burgerga/shinyTime.svg?branch=master)](https://travis-ci.org/burgerga/shinyTime)
16+
![](http://www.r-pkg.org/badges/version/shinyTime)
17+
![](http://cranlogs.r-pkg.org/badges/grand-total/shinyTime)
18+
[![Build Status](https://travis-ci.org/burgerga/shinyTime.svg?branch=master)](https://travis-ci.org/burgerga/shinyTime)
1719

1820
This package provides a `timeInput` widget for Shiny. This widget allows intuitive time input in the
19-
`[hh]:[mm]:[ss]` (24H) format by using a separate numeric input for each part of the time.
20-
Setting and getting of the time in R is done with 'DateTimeClasses' objects.
21+
`[hh]:[mm]:[ss]` or `[hh]:[mm]` (24H) format by using a separate numeric input for each time
22+
component. Setting and getting of the time in R is done with 'DateTimeClasses' objects.
2123

2224
#Usage
2325

@@ -33,22 +35,31 @@ ui <- fluidPage(
3335
timeInput("time2", "Time:", value = Sys.time()),
3436
3537
# Set to custom time
36-
timeInput("time3", "Time:", value = strptime("12:34:56", "%T"))
38+
timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
39+
40+
# Use %H:%M format
41+
timeInput("time4", "Time:", seconds = FALSE)
3742
)
3843
```
3944

40-
Note that setting an inital value is done with a [`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses) class,
41-
in the same way as setting a date in `dateInput` can be done with a `Date` class.
45+
Note that setting an inital value is done with a
46+
[`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses) object, in the same way as setting
47+
a date in `dateInput` can be done with a `Date` object.
4248

43-
The value retrieved will alse be in `DateTime` class. You need
44-
to convert it to character to be able to print the time, as the default character representation
45-
does not include the time. An example:
49+
The value retrieved will also be a `DateTime` object. You need to convert it to character to be able
50+
to print the time, as the default character representation does not include it. An example:
4651

4752
```
4853
server <- function(input, output) {
4954
# Print the time in [hh]:[mm]:[ss] everytime it changes
50-
observe(print(strftime(input$time1, "%T"))),
55+
observe(print(strftime(input$time1, "%T")))
56+
57+
# Print the time in [hh]:[mm] everytime it changes
58+
observe(print(strftime(input$time4, "%R")))
5159
}
5260
```
5361

54-
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')`.
62+
For a fully functional app go to the
63+
[ShinyApps example](https://burgerga.shinyapps.io/shinyTimeExample/) (can be a bit slow) or try the
64+
`shinyTime::shinyTimeExample()` function after installing the package with
65+
`install.packages('shinyTime')`.

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ shinyTime
44
<!-- README.md is generated from README.Rmd. Please edit that file -->
55
![](http://www.r-pkg.org/badges/version/shinyTime) ![](http://cranlogs.r-pkg.org/badges/grand-total/shinyTime) [![Build Status](https://travis-ci.org/burgerga/shinyTime.svg?branch=master)](https://travis-ci.org/burgerga/shinyTime)
66

7-
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.
7+
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.
88

99
Usage
1010
=====
@@ -19,16 +19,22 @@ As the `shinyTime` package mimics the existing shiny functionality, using the pa
1919
timeInput("time2", "Time:", value = Sys.time()),
2020

2121
# Set to custom time
22-
timeInput("time3", "Time:", value = strptime("12:34:56", "%T"))
22+
timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
23+
24+
# Use %H:%M format
25+
timeInput("time4", "Time:", seconds = FALSE)
2326
)
2427

25-
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.
28+
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.
2629

27-
The value retrieved 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:
30+
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:
2831

2932
server <- function(input, output) {
3033
# Print the time in [hh]:[mm]:[ss] everytime it changes
31-
observe(print(strftime(input$time1, "%T"))),
34+
observe(print(strftime(input$time1, "%T")))
35+
36+
# Print the time in [hh]:[mm] everytime it changes
37+
observe(print(strftime(input$time4, "%R")))
3238
}
3339

3440
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')`.

0 commit comments

Comments
 (0)