Commit 6820a3f580c1a2e435eafa29541e9d285901bab9
1 parent
1bcc750d
Exists in
master
and in
29 other branches
ActionItem1050: better time formatting
Showing
2 changed files
with
4 additions
and
4 deletions
Show diff stats
app/helpers/dates_helper.rb
@@ -35,7 +35,7 @@ module DatesHelper | @@ -35,7 +35,7 @@ module DatesHelper | ||
35 | # formats a datetime for displaying. | 35 | # formats a datetime for displaying. |
36 | def show_time(time) | 36 | def show_time(time) |
37 | if time | 37 | if time |
38 | - time.strftime(_('%d %B %Y, %H:%M')) | 38 | + _('%{day} %{month} %{year}, %{hour}:%{minutes}') % { :year => time.year, :month => month_name(time.month), :day => time.day, :hour => time.hour, :minutes => time.min } |
39 | else | 39 | else |
40 | '' | 40 | '' |
41 | end | 41 | end |
test/unit/dates_helper_test.rb
@@ -131,9 +131,9 @@ class DatesHelperTest < Test::Unit::TestCase | @@ -131,9 +131,9 @@ class DatesHelperTest < Test::Unit::TestCase | ||
131 | end | 131 | end |
132 | 132 | ||
133 | should 'translate time' do | 133 | should 'translate time' do |
134 | - time = mock | ||
135 | - expects(:_).with('%d %B %Y, %H:%M').returns('the time') | ||
136 | - time.expects(:strftime).with('the time').returns('translated time') | 134 | + time = Time.parse('25 May 2009, 12:47') |
135 | + expects(:_).with('%{day} %{month} %{year}, %{hour}:%{minutes}').returns('translated time') | ||
136 | + stubs(:_).with('May').returns("Maio") | ||
137 | assert_equal 'translated time', show_time(time) | 137 | assert_equal 'translated time', show_time(time) |
138 | end | 138 | end |
139 | 139 |