1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Dates and times interpret empty strings as nil rather than 2000-01-01. Closes #4830.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4327 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jeremy Kemper 2006-05-07 07:52:08 +00:00
parent d59f3a78a4
commit d08d89c092
3 changed files with 29 additions and 1 deletions

View file

@ -1,5 +1,7 @@
*SVN*
* Dates and times interpret empty strings as nil rather than 2000-01-01. #4830 [kajism@yahoo.com]
* Allow :uniq => true with has_many :through associations. [Jeremy Kemper]
* Ensure that StringIO is always available for the Schema dumper. [Marcel Molina Jr.]

View file

@ -115,6 +115,7 @@ module ActiveRecord
def self.string_to_dummy_time(string)
return string unless string.is_a?(String)
return nil if string.empty?
time_array = ParseDate.parsedate(string)
# pad the resulting array with dummy date information
time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1;

View file

@ -0,0 +1,25 @@
require 'abstract_unit'
require 'fixtures/topic'
require 'fixtures/task'
class EmptyDateTimeTest < Test::Unit::TestCase
def test_assign_empty_date_time
task = Task.new
task.starting = ''
task.ending = nil
assert_nil task.starting
assert_nil task.ending
end
def test_assign_empty_date
topic = Topic.new
topic.last_read = ''
assert_nil topic.last_read
end
def test_assign_empty_time
topic = Topic.new
topic.bonus_time = ''
assert_nil topic.bonus_time
end
end