From ca412798bfdc87188eae98f39608b3f8a395574d Mon Sep 17 00:00:00 2001 From: David Reese Date: Tue, 18 Nov 2008 13:51:09 +0800 Subject: [PATCH] removed ordinal formatting (Nov 15, not Nov 15th) Signed-off-by: rick --- lib/active_reload/relative_time_helpers.rb | 10 ++--- test/relative_time_helpers_test.rb | 44 +++++++++++----------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/active_reload/relative_time_helpers.rb b/lib/active_reload/relative_time_helpers.rb index 8fdaebe..ac3bf92 100644 --- a/lib/active_reload/relative_time_helpers.rb +++ b/lib/active_reload/relative_time_helpers.rb @@ -25,7 +25,7 @@ def relative_date(time) else fmt = time_output[:initial_format].dup fmt << time_output[:year_format] unless date.year == today.year - time.strftime_ordinalized(fmt) + time.strftime(fmt) end end @@ -36,11 +36,11 @@ def relative_date_span(times) relative_date(times.first) else first = times.first; last = times.last; now = time_class.now - returning [first.strftime_ordinalized('%b %d')] do |arr| + returning [first.strftime('%b %d')] do |arr| arr << ", #{first.year}" unless first.year == last.year arr << ' - ' arr << last.strftime('%b') << ' ' unless first.year == last.year && first.month == last.month - arr << last.day.ordinalize + arr << last.day arr << ", #{last.year}" unless first.year == last.year && last.year == now.year end.to_s end @@ -59,13 +59,13 @@ def relative_time_span(times) first = times.first; last = times.last; now = time_class.now [prettier_time(first)].tap do |arr| arr << ' ' - arr << first.strftime_ordinalized('%b %d') + arr << first.strftime('%b %d') arr << ", #{first.year}" unless first.year == last.year arr << ' - ' arr << prettier_time(last) arr << ' ' arr << last.strftime('%b') << ' ' unless first.year == last.year && first.month == last.month - arr << last.day.ordinalize + arr << last.day arr << ", #{last.year}" unless first.year == last.year && last.year == now.year end.to_s end diff --git a/test/relative_time_helpers_test.rb b/test/relative_time_helpers_test.rb index 3ecbf5f..e18e768 100644 --- a/test/relative_time_helpers_test.rb +++ b/test/relative_time_helpers_test.rb @@ -27,77 +27,77 @@ def test_should_show_tomorrow end def test_should_show_date_with_year - assert_equal 'Nov 15th, 2005', relative_date(Time.utc(2005, 11, 15)) + assert_equal 'Nov 15, 2005', relative_date(Time.utc(2005, 11, 15)) end def test_should_show_date - assert_equal 'Nov 15th', relative_date(Time.utc(2007, 11, 15)) + assert_equal 'Nov 15', relative_date(Time.utc(2007, 11, 15)) end def test_should_show_date_span_on_the_same_day - assert_equal 'Nov 15th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 15)]) + assert_equal 'Nov 15', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 15)]) end def test_should_show_date_span_on_the_same_day_on_different_year - assert_equal 'Nov 15th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 15)]) + assert_equal 'Nov 15, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 15)]) end def test_should_show_date_span_on_the_same_month - assert_equal 'Nov 15th - 16th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 16)]) - assert_equal 'Nov 15th - 16th', relative_date_span([Time.utc(2007, 11, 16), Time.utc(2007, 11, 15)]) + assert_equal 'Nov 15 - 16', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 16)]) + assert_equal 'Nov 15 - 16', relative_date_span([Time.utc(2007, 11, 16), Time.utc(2007, 11, 15)]) end def test_should_show_date_span_on_the_same_month_on_different_year - assert_equal 'Nov 15th - 16th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 16)]) - assert_equal 'Nov 15th - 16th, 2006', relative_date_span([Time.utc(2006, 11, 16), Time.utc(2006, 11, 15)]) + assert_equal 'Nov 15 - 16, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 16)]) + assert_equal 'Nov 15 - 16, 2006', relative_date_span([Time.utc(2006, 11, 16), Time.utc(2006, 11, 15)]) end def test_should_show_date_span_on_the_different_month - assert_equal 'Nov 15th - Dec 16th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 12, 16)]) - assert_equal 'Nov 15th - Dec 16th', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2007, 11, 15)]) + assert_equal 'Nov 15 - Dec 16', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 12, 16)]) + assert_equal 'Nov 15 - Dec 16', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2007, 11, 15)]) end def test_should_show_date_span_on_the_different_month_on_different_year - assert_equal 'Nov 15th - Dec 16th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 12, 16)]) - assert_equal 'Nov 15th - Dec 16th, 2006', relative_date_span([Time.utc(2006, 12, 16), Time.utc(2006, 11, 15)]) + assert_equal 'Nov 15 - Dec 16, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 12, 16)]) + assert_equal 'Nov 15 - Dec 16, 2006', relative_date_span([Time.utc(2006, 12, 16), Time.utc(2006, 11, 15)]) end def test_should_show_date_span_on_the_different_year - assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2007, 12, 16)]) - assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2006, 11, 15)]) + assert_equal 'Nov 15, 2006 - Dec 16, 2007', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2007, 12, 16)]) + assert_equal 'Nov 15, 2006 - Dec 16, 2007', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2006, 11, 15)]) end # Time, Single Date def test_should_show_time_span_on_the_same_day_with_same_time - assert_equal '5:00 PM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 17, 00, 00), Time.utc(2007, 11, 15, 17, 00, 00)]) + assert_equal '5:00 PM Nov 15', relative_time_span([Time.utc(2007, 11, 15, 17, 00, 00), Time.utc(2007, 11, 15, 17, 00, 00)]) end def test_should_show_time_span_on_the_same_day_with_same_time_on_different_year - assert_equal '5:00 PM Nov 15th, 2006', relative_time_span([Time.utc(2006, 11, 15, 17, 0), Time.utc(2006, 11, 15, 17, 0)]) + assert_equal '5:00 PM Nov 15, 2006', relative_time_span([Time.utc(2006, 11, 15, 17, 0), Time.utc(2006, 11, 15, 17, 0)]) end def test_should_show_time_span_on_the_same_day_with_different_times_in_same_half_of_day - assert_equal '10:00 - 11:00 AM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 10), Time.utc(2007, 11, 15, 11, 0)]) + assert_equal '10:00 - 11:00 AM Nov 15', relative_time_span([Time.utc(2007, 11, 15, 10), Time.utc(2007, 11, 15, 11, 0)]) end def test_should_show_time_span_on_the_same_day_with_different_times_in_different_half_of_day - assert_equal '10:00 AM - 2:00 PM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 11, 15, 14, 0)]) + assert_equal '10:00 AM - 2:00 PM Nov 15', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 11, 15, 14, 0)]) end def test_should_show_time_span_on_the_same_day_with_different_times_in_different_half_of_day_in_different_year - assert_equal '10:00 AM - 2:00 PM Nov 15th, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 11, 15, 14, 0)]) + assert_equal '10:00 AM - 2:00 PM Nov 15, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 11, 15, 14, 0)]) end def test_should_show_time_span_on_different_days_in_same_year - assert_equal '10:00 AM Nov 15th - 2:00 PM Dec 16th, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 12, 16, 14, 0)]) + assert_equal '10:00 AM Nov 15 - 2:00 PM Dec 16, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 12, 16, 14, 0)]) end def test_should_show_time_span_on_different_days_in_different_years - assert_equal '10:00 AM Nov 15th, 2006 - 2:00 PM Dec 16th, 2007', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)]) + assert_equal '10:00 AM Nov 15, 2006 - 2:00 PM Dec 16, 2007', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)]) end def test_should_show_time_span_on_different_days_in_current_year - assert_equal '10:00 AM Nov 15th - 2:00 PM Dec 16th', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)]) + assert_equal '10:00 AM Nov 15 - 2:00 PM Dec 16', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)]) end # prettier_time