From f831d99cc708cbbd2d0abfd96fb60f614ec10658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20S=C3=B6derlind?= Date: Mon, 2 Nov 2020 17:05:47 +0100 Subject: [PATCH] added missing trunc methods for Quarter --- stdlib/Dates/src/adjusters.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/Dates/src/adjusters.jl b/stdlib/Dates/src/adjusters.jl index 4687b22badad5..d5617ba8cf93c 100644 --- a/stdlib/Dates/src/adjusters.jl +++ b/stdlib/Dates/src/adjusters.jl @@ -2,10 +2,12 @@ ### truncation Base.trunc(dt::Date, p::Type{Year}) = Date(UTD(totaldays(year(dt), 1, 1))) +Base.trunc(dt::Date, p::Type{Quarter}) = firstdayofquarter(dt) Base.trunc(dt::Date, p::Type{Month}) = firstdayofmonth(dt) Base.trunc(dt::Date, p::Type{Day}) = dt Base.trunc(dt::DateTime, p::Type{Year}) = DateTime(trunc(Date(dt), Year)) +Base.trunc(dt::DateTime, p::Type{Quarter}) = DateTime(trunc(Date(dt), Quarter)) Base.trunc(dt::DateTime, p::Type{Month}) = DateTime(trunc(Date(dt), Month)) Base.trunc(dt::DateTime, p::Type{Day}) = DateTime(Date(dt)) Base.trunc(dt::DateTime, p::Type{Hour}) = dt - Minute(dt) - Second(dt) - Millisecond(dt)