Skip to content

Commit 810b8f4

Browse files
Sam Morrisonomus
Sam Morrison
authored andcommitted
Fix print errors on TimeTypes in 1.0 (#53)
1 parent e6711a0 commit 810b8f4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/anchoredinterval.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function Base.show(io::IO, interval::T) where T <: AnchoredInterval
191191
end
192192
end
193193

194-
function Base.print(io::IO, interval::AnchoredInterval{P, T}) where {P, T <: TimeType}
194+
function Base.print(io::IO, interval::AnchoredInterval{P, T}) where {P, T <: Union{Date, AbstractDateTime}}
195195
# Print to io in order to keep properties like :limit and :compact
196196
if get(io, :compact, false)
197197
io = IOContext(io, :limit=>true)

src/description.jl

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ function description(dt::AbstractDateTime, p::Period, suffix::String)
3232
ts = string(max_val)
3333
end
3434

35+
@static if VERSION < v"0.7.0-DEV.3216"
36+
isa(dt, Time) && return string(prefix(p), suffix, " ", ts)
37+
end
38+
3539
ds = @sprintf("%04d-%02d-%02d", year(dt), month(dt), day(dt))
3640

3741
if p isa TimePeriod

test/anchoredinterval.jl

+3
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ using Intervals: canonicalize
284284
"Inclusivity(false, true))",
285285
)
286286

287+
interval = AnchoredInterval{Second(-10)}(Time(1, 0, 0))
288+
@test_nowarn string(interval)
289+
287290
# Non-period AnchoredIntervals
288291
interval = AnchoredInterval{-10}(10)
289292
@test string(interval) == "(0 .. 10]"

0 commit comments

Comments
 (0)