Explain the results of ceiling Dates?

julia> using Dates

julia> ceil(DateTime(2013, 2, 13, 0, 31, 24), Dates.Minute(15))
2013-02-13T00:45:00

julia> ceil(DateTime(2013, 2, 13, 0, 31, 24), Dates.Minute(16))
2013-02-13T00:32:00

julia> ceil(DateTime(2013, 2, 13, 0, 31, 24), Dates.Minute(17))
2013-02-13T00:33:00

julia> ceil(DateTime(2013, 2, 11, 0, 31, 24), Dates.Minute(17))
2013-02-11T00:40:00

in R

library(lubridate)
ceiling_date(ymd_hms(“2013-02-13 00:31:24”), “15 mins”)
[1] “2013-02-13 00:45:00 UTC”
ceiling_date(ymd_hms(“2013-02-13 00:31:24”), “16 mins”)
[1] “2013-02-13 00:32:00 UTC”
ceiling_date(ymd_hms(“2013-02-13 00:31:24”), “17 mins”)
[1] “2013-02-13 00:34:00 UTC”
ceiling_date(ymd_hms(“2013-02-11 00:31:24”), “17 mins”)
[1] “2013-02-11 00:34:00 UTC”

explain the results of ceiling Dates ? thanks!

Looks like a bug to me; mind opening an issue at JuliaLang/julia?

1 Like

Julia doesn’t round based on the day you want but starting on 0000-01-01T00:00:00

https://docs.julialang.org/en/v1/stdlib/Dates/#Rounding-Epoch

What you want is probably something like that

julia> ceil(Time(0,31, 24), Minute(16))

but it is not defined

you can try

julia> ceil(Time(0, 31, 24) - Time(0), Minute(17))
2 Likes

until now I deal with date or time data using R. Anyway, thanks! it is very kind of you!