Skip to content

Commit

Permalink
fix adjust hour/minute/day for group_times with minutes
Browse files Browse the repository at this point in the history
  • Loading branch information
robitalec committed Dec 12, 2018
1 parent 4f30ff1 commit 16e28c6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions R/group_times.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,14 @@ group_times <- function(DT = NULL,

dtm[, c('adjMinute', 'adjHour', 'adjDate') :=
.(minutes, data.table::hour(itime), idate)]
dtm[data.table::hour(itime) == 23 &
minutes == 60,
c('adjMinute', 'adjHour', 'adjDate') :=
.(0, 0, idate + 1)]

dtm[minutes == 60L,
c('adjMinute', 'adjHour') :=
.(0L, adjHour + 1L)]

dtm[adjHour == 24L,
c('adjMinute', 'adjHour', 'adjDate') :=
.(0L, 0L, idate + 1)]

dtm[, timegroup := .GRP,
by = c('adjMinute', 'adjHour', 'adjDate')]
Expand Down

0 comments on commit 16e28c6

Please sign in to comment.