From 60de8c110829cb7f2df1d312ad2898633e896c24 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 28 Dec 2004 17:30:17 +0000 Subject: Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database. This is set to :local by default. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@271 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/base_test.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'activerecord/test') diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index c2a105f85d..8bbf98555d 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -327,7 +327,16 @@ class BasicsTest < Test::Unit::TestCase assert_equal 1, topic.approved assert_nil topic.last_read end - + + def test_utc_as_time_zone + Topic.default_timezone = :utc + attributes = { "bonus_time" => "5:42:00AM" } + topic = Topic.find(1) + topic.attributes = attributes + assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time + Topic.default_timezone = :local + end + def test_default_values_on_empty_strings topic = Topic.new topic.approved = nil -- cgit v1.2.3