
Summarise times across midnight
nighttime_switch.RdConverts times before cutoff to the next day before applying .fun, which
helps summarise nighttime values spanning midnight (for example, median sleep
time).
Usage
nighttime_switch(
datetime,
.fun = stats::median,
cutoff = 12 * 60 * 60,
hms = TRUE
)Examples
x <- as.POSIXct(c("2024-01-01 23:00:00", "2024-01-02 01:00:00"), tz = "UTC")
nighttime_switch(x)
#> 00:00:00