Skip to content

Commit df286d0

Browse files
committed
Fix print of DataValue times and dates
1 parent 5266bf6 commit df286d0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/TableShowUtils.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,10 @@ function printHTMLtable(io, source; force_unknown_rows=false)
165165
print(io, "<tr>")
166166
for c in values(r)
167167
print(io, "<td>")
168-
if c isa Dates.AbstractTime
168+
if c isa Dates.AbstractTime
169169
Markdown.htmlesc(io, sprint(io->print(IOContext(io, :compact => true),c)))
170+
elseif c isa DataValues.DataValue && DataValues.hasvalue(c) && c[] isa Dates.AbstractDateTime
171+
Markdown.htmlesc(io, sprint(io->print(IOContext(io, :compact => true),c[])))
170172
else
171173
Markdown.htmlesc(io, sprint(io->show(IOContext(io, :compact => true),c)))
172174
end

test/test_tableshowutils.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,15 @@
3636
end
3737

3838
@testitem "DateTime" begin
39-
using Dates
39+
using Dates, DataValues
4040

4141
source = [(a=1,b=DateTime(2010, 5, 6)),(a=2,b=DateTime(2011, 5, 6))]
4242

4343
@test sprint(TableShowUtils.printHTMLtable, source) == """
4444
<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2010-05-06T00:00:00</td></tr><tr><td>2</td><td>2011-05-06T00:00:00</td></tr></tbody></table>"""
45+
46+
source2 = [(a=1,b=DataValue(DateTime(2010, 5, 6))),(a=2,b=NA)]
47+
48+
@test sprint(TableShowUtils.printHTMLtable, source2) == """
49+
<table><thead><tr><th>a</th><th>b</th></tr></thead><tbody><tr><td>1</td><td>2010-05-06T00:00:00</td></tr><tr><td>2</td><td>#NA</td></tr></tbody></table>"""
4550
end

0 commit comments

Comments
 (0)