From 889538c21f52aff8f50a2334b35ae2b9a1a4779d Mon Sep 17 00:00:00 2001 From: Chirag Anand Date: Thu, 25 Apr 2024 13:08:39 +0530 Subject: [PATCH] use Dates.Period instead of the entire Union --- src/endpoints.jl | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/src/endpoints.jl b/src/endpoints.jl index 440083a..1aaee94 100644 --- a/src/endpoints.jl +++ b/src/endpoints.jl @@ -1,20 +1,7 @@ """ # Computing end points ```julia -endpoints(timestamps::AbstractVector{T}, on::V) where {T<:Union{Date, DateTime, Time}, - V<:Union{ - Year, - Quarter, - Month, - Week, - Day, - Hour, - Minute, - Second, - Millisecond, - Microsecond, - Nanosecond - }} +endpoints(timestamps::AbstractVector{T}, on::V) where {T<:Union{Date, DateTime, Time}, V<:Dates.Period} endpoints(ts::TSFrame, on::T) where {T<:Dates.Period} endpoints(ts::TSFrame, on::Symbol, k::Int=1) endpoints(ts::TSFrame, on::String, k::Int=1) @@ -317,20 +304,7 @@ function endpoints(ts::TSFrame, on::Function, k::Int=1) endpoints(index(ts), on, k) end -function endpoints(timestamps::AbstractVector{T}, on::V)::Vector{Int} where {T<:Union{Date, DateTime, Time}, - V<:Union{ - Year, - Quarter, - Month, - Week, - Day, - Hour, - Minute, - Second, - Millisecond, - Microsecond, - Nanosecond - }} +function endpoints(timestamps::AbstractVector{T}, on::V)::Vector{Int} where {T<:Union{Date, DateTime, Time}, V<:Dates.Period} if (on.value <= 0) throw(DomainError("`on.value` needs to be greater than 0")) end