Skip to content

Commit

Permalink
Document utils as internal
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerga committed Apr 15, 2024
1 parent 57d1899 commit 5a68a5a
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/input-time.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ shinyTimeExample <- function() {
#' App to test the input with a variety of options
#'
#' @importFrom shiny runApp
#' @keywords internal
shinyTimeDebug <- function() {
runApp(system.file('debug', package='shinyTime', mustWork=T), display.mode='normal')
}
6 changes: 6 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param inputId The `input` slot
#' @param label The label text
#' @return A label tag
#' @keywords internal
shinyInputLabel <- function (inputId, label = NULL)
{
tags$label(label, class = "control-label", class = if (is.null(label))
Expand Down Expand Up @@ -38,19 +39,22 @@ dateToTimeList <- function(value){
#' Convert a list to a time object
#' @param value A list with the hour, minute and second components
#' @return A time object
#' @keywords internal
timeListToDate <- function(value) {
timeStringToDate(paste(c(value$hour, value$min, value$sec), collapse = ':'))
}

#' Convert a string to a time object
#' @param string A string with the time in the format "HH:MM:SS"
#' @return A time object
#' @keywords internal
timeStringToDate <- function(string) {
strptime(string, format = "%T")
}

#' Get the default time
#' @return A time object with the value "00:00:00"
#' @keywords internal
getDefaultTime <- function(){
timeStringToDate("00:00:00")
}
Expand All @@ -60,6 +64,7 @@ getDefaultTime <- function(){
#' @param x A time object
#' @param tol The tolerance for rounding
#' @return A time object rounded to the nearest minute
#' @keywords internal
is.wholenumber <- function(x, tol = .Machine$double.eps^0.5){
abs(x - round(x)) < tol
}
Expand All @@ -68,6 +73,7 @@ is.wholenumber <- function(x, tol = .Machine$double.eps^0.5){
#' @param time A time object
#' @param minutes The number of minutes to round to
#' @return A time object rounded to the nearest minute
#' @keywords internal
roundTime <- function(time, minutes) {
stopifnot(any(class(time) %in% c("POSIXt", "hms")))
stopifnot(is.wholenumber(minutes))
Expand Down
1 change: 1 addition & 0 deletions man/dateToTimeList.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/dropNulls.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/getDefaultTime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/is.wholenumber.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/roundTime.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/shinyInputLabel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/shinyTimeDebug.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/timeListToDate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions man/timeStringToDate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a68a5a

Please sign in to comment.