dates <- seq(
from = as.POSIXct("2024-01-01 00:00:00", tz = "UTC"),
to = as.POSIXct("2024-01-02 00:00:00", tz = "UTC"),
by = "6 hours"
)
fractional_day_of_year(dates) # Returns 0.00, 0.25, 0.50, 0.75, 1.00
# End of year
dt_end <- as.POSIXct("2024-12-31 23:00:00", tz = "UTC")
fractional_day_of_year(dt_end) # Returns ~365.958
Run the code above in your browser using DataLab