aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/time_ext_test.rb
diff options
context:
space:
mode:
authorAnatoli Makarevich <makaroni4@gmail.com>2013-06-07 18:37:41 +0400
committerAnatoli Makarevich <makaroni4@gmail.com>2013-07-28 23:29:50 +0400
commit1b6bbb09532e164bf373c1cd273e4ec9062b9e56 (patch)
tree3e55dbc0f5d840ec6f79ddb4c88e4354a4802775 /activesupport/test/core_ext/time_ext_test.rb
parent94725b81f5588e4b0f43222c4f142c3135941b4b (diff)
downloadrails-1b6bbb09532e164bf373c1cd273e4ec9062b9e56.tar.gz
rails-1b6bbb09532e164bf373c1cd273e4ec9062b9e56.tar.bz2
rails-1b6bbb09532e164bf373c1cd273e4ec9062b9e56.zip
Added Time#middle_of_day
Added middle_of_day method to Date and DateTime
Diffstat (limited to 'activesupport/test/core_ext/time_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 4e53aff00b..66631d1f5f 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -117,6 +117,18 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
end
end
+ def test_middle_of_day
+ assert_equal Time.local(2005,2,4,12,0,0), Time.local(2005,2,4,10,10,10).middle_of_day
+ with_env_tz 'US/Eastern' do
+ assert_equal Time.local(2006,4,2,12,0,0), Time.local(2006,4,2,10,10,10).middle_of_day, 'start DST'
+ assert_equal Time.local(2006,10,29,12,0,0), Time.local(2006,10,29,10,10,10).middle_of_day, 'ends DST'
+ end
+ with_env_tz 'NZ' do
+ assert_equal Time.local(2006,3,19,12,0,0), Time.local(2006,3,19,10,10,10).middle_of_day, 'ends DST'
+ assert_equal Time.local(2006,10,1,12,0,0), Time.local(2006,10,1,10,10,10).middle_of_day, 'start DST'
+ end
+ end
+
def test_beginning_of_hour
assert_equal Time.local(2005,2,4,19,0,0), Time.local(2005,2,4,19,30,10).beginning_of_hour
end