Skip to content

Commit

Permalink
Merge branch 'elapsedTime' into Pbug
Browse files Browse the repository at this point in the history
  • Loading branch information
Eliot McIntire committed Jun 7, 2024
2 parents 7c9ad8a + 29ddab0 commit 16d57dc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions R/simList-accessors.R
Original file line number Diff line number Diff line change
Expand Up @@ -3351,22 +3351,20 @@ elapsedTime.simList <- function(x, byEvent = TRUE, units = "auto", ...) {
if (identical(units, "auto")) {
unt <- "secs"
if (any(a > minutesInSeconds)) {
if (any(a > hoursInSeconds)) {
if (any(a > daysInSeconds)) {
unt <- "days"
}
} else {
unt <- "hours"
}
} else {
unt <- "mins"
} else if (any(a > hoursInSeconds)) {
unt <- "hours"
} else if (any(a > daysInSeconds)) {
unt <- "days"
}
st <- Sys.time()
a <- round(difftime(a + st, st, units = unt), 3) # work around for forcing a non seconds unit, allowing "auto"
} else {
# This one won't allow "auto"
unt <- units
units(a) <- units
}
st <- Sys.time()
a <- round(difftime(a + st, st, units = unt), 3) # work around for forcing a non seconds unit, allowing "auto"

ret[, elapsedTime := a]
} else {
ret <- NULL
Expand Down

0 comments on commit 16d57dc

Please sign in to comment.