Skip to content

Commit 37dbfc1

Browse files
committed
Revert "Fix repr on DateTime (#30200)"
This reverts commit 8d8b3d9.
1 parent 1d7c1fa commit 37dbfc1

File tree

4 files changed

+26
-65
lines changed

4 files changed

+26
-65
lines changed

NEWS.md

-4
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ Standard library changes
8181
form `kron(u, v')`, `u * v'`, and `u .* v'` where `u` and `v` are sparse vectors or column
8282
views ([#24980]).
8383

84-
#### Dates
85-
* Fixed `repr` such that it displays `DateTime` as it would be entered in Julia ([#30200]).
86-
8784
#### Statistics
8885
* `quantile` now accepts in all cases collections whose `eltype` is not a subtype of `Number` ([#30938]).
8986

@@ -110,7 +107,6 @@ External dependencies
110107
[#29790]: https://github.com/JuliaLang/julia/issues/29790
111108
[#29998]: https://github.com/JuliaLang/julia/issues/29998
112109
[#30061]: https://github.com/JuliaLang/julia/issues/30061
113-
[#30200]: https://github.com/JuliaLang/julia/issues/30200
114110
[#30298]: https://github.com/JuliaLang/julia/issues/30298
115111
[#30323]: https://github.com/JuliaLang/julia/issues/30323
116112
[#30372]: https://github.com/JuliaLang/julia/issues/30372

stdlib/Dates/docs/src/index.md

+23-24
Original file line numberDiff line numberDiff line change
@@ -400,29 +400,29 @@ As a bonus, all period arithmetic objects work directly with ranges:
400400

401401
```jldoctest
402402
julia> dr = Date(2014,1,29):Day(1):Date(2014,2,3)
403-
Date(2014, 1, 29):1 day:Date(2014, 2, 3)
403+
2014-01-29:1 day:2014-02-03
404404
405405
julia> collect(dr)
406406
6-element Array{Date,1}:
407-
Date(2014, 1, 29)
408-
Date(2014, 1, 30)
409-
Date(2014, 1, 31)
410-
Date(2014, 2, 1)
411-
Date(2014, 2, 2)
412-
Date(2014, 2, 3)
407+
2014-01-29
408+
2014-01-30
409+
2014-01-31
410+
2014-02-01
411+
2014-02-02
412+
2014-02-03
413413
414414
julia> dr = Date(2014,1,29):Dates.Month(1):Date(2014,07,29)
415-
Date(2014, 1, 29):1 month:Date(2014, 7, 29)
415+
2014-01-29:1 month:2014-07-29
416416
417417
julia> collect(dr)
418418
7-element Array{Date,1}:
419-
Date(2014, 1, 29)
420-
Date(2014, 2, 28)
421-
Date(2014, 3, 29)
422-
Date(2014, 4, 29)
423-
Date(2014, 5, 29)
424-
Date(2014, 6, 29)
425-
Date(2014, 7, 29)
419+
2014-01-29
420+
2014-02-28
421+
2014-03-29
422+
2014-04-29
423+
2014-05-29
424+
2014-06-29
425+
2014-07-29
426426
```
427427

428428
## Adjuster Functions
@@ -492,15 +492,14 @@ julia> filter(dr) do x
492492
Dates.dayofweekofmonth(x) == 2
493493
end
494494
8-element Array{Date,1}:
495-
Date(2014, 4, 8)
496-
Date(2014, 5, 13)
497-
Date(2014, 6, 10)
498-
Date(2014, 7, 8)
499-
Date(2014, 8, 12)
500-
Date(2014, 9, 9)
501-
Date(2014, 10, 14)
502-
Date(2014, 11, 11)
503-
495+
2014-04-08
496+
2014-05-13
497+
2014-06-10
498+
2014-07-08
499+
2014-08-12
500+
2014-09-09
501+
2014-10-14
502+
2014-11-11
504503
```
505504

506505
Additional examples and tests are available in [`stdlib/Dates/test/adjusters.jl`](https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/test/adjusters.jl).

stdlib/Dates/src/io.jl

+1-35
Original file line numberDiff line numberDiff line change
@@ -530,48 +530,14 @@ end
530530
# show
531531

532532
function Base.show(io::IO, dt::DateTime)
533-
if get(io, :compact, false)
534-
print(io, dt)
535-
else
536-
y,m,d = yearmonthday(dt)
537-
h = hour(dt)
538-
mi = minute(dt)
539-
s = second(dt)
540-
ms = millisecond(dt)
541-
if ms == 0
542-
print(io, "DateTime($y, $m, $d, $h, $mi, $s)")
543-
else
544-
print(io, "DateTime($y, $m, $d, $h, $mi, $s, $ms)")
545-
end
546-
end
547-
end
548-
549-
function Base.show(io::IO, ::MIME"text/plain", dt::DateTime)
550-
print(io, dt)
551-
end
552-
553-
function Base.show(io::IO, ::MIME"text/plain", dt::Date)
554-
print(io, dt)
555-
end
556-
557-
function Base.show(io::IO, dt::Date)
558-
if get(io, :compact, false)
559-
print(io, dt)
560-
else
561-
y,m,d = yearmonthday(dt)
562-
print(io, "Date($y, $m, $d)")
563-
end
564-
end
565-
566-
function Base.print(io::IO, dt::DateTime)
567533
if millisecond(dt) == 0
568534
format(io, dt, dateformat"YYYY-mm-dd\THH:MM:SS")
569535
else
570536
format(io, dt, dateformat"YYYY-mm-dd\THH:MM:SS.s")
571537
end
572538
end
573539

574-
function Base.print(io::IO, dt::Date)
540+
function Base.show(io::IO, dt::Date)
575541
format(io, dt, dateformat"YYYY-mm-dd")
576542
end
577543

stdlib/Dates/test/io.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Dates
77

88
@testset "string/show representation of Date" begin
99
@test string(Dates.Date(1, 1, 1)) == "0001-01-01" # January 1st, 1 AD/CE
10-
@test sprint(show, Dates.Date(1, 1, 1)) == "Date(1, 1, 1)"
10+
@test sprint(show, Dates.Date(1, 1, 1)) == "0001-01-01"
1111
@test string(Dates.Date(0, 12, 31)) == "0000-12-31" # December 31, 1 BC/BCE
1212
@test Dates.Date(1, 1, 1) - Dates.Date(0, 12, 31) == Dates.Day(1)
1313
@test Dates.Date(Dates.UTD(-306)) == Dates.Date(0, 2, 29)
@@ -16,7 +16,7 @@ using Dates
1616
@test string(Dates.Date(-1000000, 1, 1)) == "-1000000-01-01"
1717
@test string(Dates.Date(1000000, 1, 1)) == "1000000-01-01"
1818
@test string(Dates.DateTime(2000, 1, 1, 0, 0, 0, 1)) == "2000-01-01T00:00:00.001"
19-
@test sprint(show, Dates.DateTime(2000, 1, 1, 0, 0, 0, 1)) == "DateTime(2000, 1, 1, 0, 0, 0, 1)"
19+
@test sprint(show, Dates.DateTime(2000, 1, 1, 0, 0, 0, 1)) == "2000-01-01T00:00:00.001"
2020
@test string(Dates.DateTime(2000, 1, 1, 0, 0, 0, 2)) == "2000-01-01T00:00:00.002"
2121
@test string(Dates.DateTime(2000, 1, 1, 0, 0, 0, 500)) == "2000-01-01T00:00:00.5"
2222
@test string(Dates.DateTime(2000, 1, 1, 0, 0, 0, 998)) == "2000-01-01T00:00:00.998"

0 commit comments

Comments
 (0)