diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2015-04-22 12:01:58 -0400 |
---|---|---|
committer | Andrew White <andyw@pixeltrix.co.uk> | 2015-04-22 12:05:07 -0400 |
commit | 5302d244eb2f81cba1bb0f1f6c8319464c467706 (patch) | |
tree | 8c5780b57636e2e6f6a3ac4de386a91354bb0cba /activesupport/test | |
parent | a5e507fa0b8180c3d97458a9b86c195e9857d8f6 (diff) | |
download | rails-5302d244eb2f81cba1bb0f1f6c8319464c467706.tar.gz rails-5302d244eb2f81cba1bb0f1f6c8319464c467706.tar.bz2 rails-5302d244eb2f81cba1bb0f1f6c8319464c467706.zip |
Refactor ActiveSupport::Timezone#strptime
Make strptime behave more like parse when components are missing and
share behavior between the two methods.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/time_zone_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb index 1293ccfd58..ea90caa143 100644 --- a/activesupport/test/time_zone_test.rb +++ b/activesupport/test/time_zone_test.rb @@ -376,6 +376,15 @@ class TimeZoneTest < ActiveSupport::TestCase assert_equal zone, twz.time_zone end + def test_strptime_with_day_omitted + with_env_tz 'US/Eastern' do + zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'] + assert_equal Time.local(2000, 2, 1), zone.strptime('Feb', '%b', Time.local(2000, 1, 1)) + assert_equal Time.local(2005, 2, 1), zone.strptime('Feb 2005', '%b %Y', Time.local(2000, 1, 1)) + assert_equal Time.local(2005, 2, 2), zone.strptime('2 Feb 2005', '%e %b %Y', Time.local(2000, 1, 1)) + end + end + def test_utc_offset_lazy_loaded_from_tzinfo_when_not_passed_in_to_initialize tzinfo = TZInfo::Timezone.get('America/New_York') zone = ActiveSupport::TimeZone.create(tzinfo.name, nil, tzinfo) |