Skip to content

Commit 7a7a3af

Browse files
committed
Remove hack to prevent years < 1970 in DateTime
Time can handle dates before epoch perfectly fine. The test here is probably something from ancient times and breaks stuff these days without reason.
1 parent 30e4230 commit 7a7a3af

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

lib/xmlrpc/datetime.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,10 @@ def initialize(year, month, day, hour, min, sec)
8787
end
8888

8989
# Return a Time object of the date/time which represents +self+.
90-
# If the <code>@year</code> is below 1970, this method returns +nil+,
91-
# because Time cannot handle years below 1970.
9290
#
9391
# The timezone used is GMT.
9492
def to_time
95-
if @year >= 1970
96-
Time.gm(*to_a)
97-
else
98-
nil
99-
end
93+
Time.gm(*to_a)
10094
end
10195

10296
# Return a Date object of the date which represents +self+.

test/test_datetime.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,18 @@ def test_to_time1
130130
end
131131

132132
def test_to_time2
133-
dt = createDateTime()
134-
dt.year = 1969
133+
y, m, d, h, mi, s = 1969, 3, 24, 12, 0, 5
134+
dt = XMLRPC::DateTime.new(y, m, d, h, mi, s)
135+
time = dt.to_time
135136

136-
assert_nil(dt.to_time)
137+
assert_not_nil(time)
138+
139+
assert_equal(y, time.year)
140+
assert_equal(m, time.month)
141+
assert_equal(d, time.day)
142+
assert_equal(h, time.hour)
143+
assert_equal(mi, time.min)
144+
assert_equal(s, time.sec)
137145
end
138146

139147
def test_to_date1

0 commit comments

Comments
 (0)