Skip to content

Commit

Permalink
changed make_difftime to chose the unit appropriate for displaying th…
Browse files Browse the repository at this point in the history
…e smallest duration in the vector for the entire vector
  • Loading branch information
garrettgman committed Apr 7, 2010
1 parent 2037255 commit 0ae922e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/ops.durations.r
Expand Up @@ -167,13 +167,13 @@ add_dates <- function(e1, e2){
#' make_difftime(3600)
make_difftime <- function (x) {
seconds <- abs(x)
if (all(seconds < 60))
if (any(seconds < 60))
units <- "secs"
else if (all(seconds < 3600))
else if (any(seconds < 3600))
units <- "mins"
else if (all(seconds < 86400))
else if (any(seconds < 86400))
units <- "hours"
else if (all(seconds < 604800))
else if (any(seconds < 604800))
units <- "days"
else units <- "weeks"

Expand Down

0 comments on commit 0ae922e

Please sign in to comment.