From 6f0ebe040a14db2dde7ef85917eb71e7782ffeab Mon Sep 17 00:00:00 2001 From: Kirill Radzikhovskyy Date: Tue, 17 May 2011 16:31:09 +1000 Subject: Year 0 should fall to nil only if month and day are also 0 --- activerecord/lib/active_record/connection_adapters/column.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/connection_adapters/column.rb b/activerecord/lib/active_record/connection_adapters/column.rb index 4e3d8a096f..3eddb69e73 100644 --- a/activerecord/lib/active_record/connection_adapters/column.rb +++ b/activerecord/lib/active_record/connection_adapters/column.rb @@ -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 -- cgit v1.2.3