Permalink
Browse files

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

  • Loading branch information...
1 parent 2033ff8 commit 6f0ebe040a14db2dde7ef85917eb71e7782ffeab Kirill Radzikhovskyy committed May 17, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/connection_adapters/column.rb
@@ -189,7 +189,7 @@ def new_date(year, mon, mday)
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

0 comments on commit 6f0ebe0

Please sign in to comment.