Year 0 should fall to nil only if month and day are also 0

This commit is contained in:
Kirill Radzikhovskyy
2011-05-17 16:31:09 +10:00
parent 2033ff825b
commit 6f0ebe040a

View File

@@ -189,7 +189,7 @@ module ActiveRecord
def new_time(year, mon, mday, hour, min, sec, microsec)
# Treat 0000-00-00 00:00:00 as nil.
return nil if year.nil? || year == 0
return nil if year.nil? || (year == 0 && mon == 0 && mday == 0)
Time.time_with_datetime_fallback(Base.default_timezone, year, mon, mday, hour, min, sec, microsec) rescue nil
end