duration objects have a method for as.numeric() but not as.integer(). Using as.integer() on a duration object returns a value but does not respect the units argument (as can be passed to as.numeric()) or warn that the units are specification is ignored. I think it would be worth implementing an as.integer() method just for safety; I've made this error myself and come across it in other peoples' code as well.
library(lubridate)
start = as_datetime("2022-07-07 13:30:00")
end = as_datetime("2022-07-07 13:45:30")
# correct
as.numeric(as.duration(end - start), "seconds")
#> [1] 930
as.integer(as.duration(end - start), "seconds")
#> [1] 930
# correct
as.numeric(as.duration(end - start), "minutes")
#> 15.5
# but this is wrong
as.integer(as.duration(end - start), "minutes")
#> 930
# this is correct
as.integer(as.numeric(as.duration(end - start), "minutes"))
#> 15
durationobjects have a method foras.numeric()but notas.integer(). Usingas.integer()on adurationobject returns a value but does not respect the units argument (as can be passed toas.numeric()) or warn that the units are specification is ignored. I think it would be worth implementing anas.integer()method just for safety; I've made this error myself and come across it in other peoples' code as well.