aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-03-22 18:43:36 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-03-22 18:43:36 +0000
commit29e33161784dae84b1e92f9acf9db7d0f1d0da64 (patch)
tree5ad2286673d14b79f2896efb0c817c8e9809809d /activesupport/test
parentea285c2f783f4f06918b9c5f5956cf4d5c5e5e25 (diff)
downloadrails-29e33161784dae84b1e92f9acf9db7d0f1d0da64.tar.gz
rails-29e33161784dae84b1e92f9acf9db7d0f1d0da64.tar.bz2
rails-29e33161784dae84b1e92f9acf9db7d0f1d0da64.zip
Ensure correct TimeWithZone#to_date
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9079 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 3bc1e3920a..fc4f61dd37 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -254,6 +254,19 @@ uses_tzinfo 'TimeWithZoneTest' do
def test_to_time
assert_equal @twz, @twz.to_time
end
+
+ def test_to_date
+ silence_warnings do # silence warnings raised by tzinfo gem
+ # 1 sec before midnight Jan 1 EST
+ assert_equal Date.new(1999, 12, 31), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 4, 59, 59), TimeZone['Eastern Time (US & Canada)'] ).to_date
+ # midnight Jan 1 EST
+ assert_equal Date.new(2000, 1, 1), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1, 5, 0, 0), TimeZone['Eastern Time (US & Canada)'] ).to_date
+ # 1 sec before midnight Jan 2 EST
+ assert_equal Date.new(2000, 1, 1), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2, 4, 59, 59), TimeZone['Eastern Time (US & Canada)'] ).to_date
+ # midnight Jan 2 EST
+ assert_equal Date.new(2000, 1, 2), ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 2, 5, 0, 0), TimeZone['Eastern Time (US & Canada)'] ).to_date
+ end
+ end
def test_to_datetime
silence_warnings do # silence warnings raised by tzinfo gem