diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9724d61..4d24b59 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -394,4 +394,12 @@ module ApplicationHelper end + def show_date(date) + date.strftime(_('%d %B %Y')) + end + + def show_time(time) + time.strftime(_('%d %B %Y, %H:%m')) + end + end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 006cfdc..a666d24 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -28,6 +28,20 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_equal '', stylesheet_import('something') end + should 'translate date' do + date = mock + expects(:_).with('%d %B %Y').returns('the date') + date.expects(:strftime).with('the date').returns('translated date') + assert_equal 'translated date', show_date(date) + end + + should 'translate time' do + time = mock + expects(:_).with('%d %B %Y, %H:%m').returns('the time') + time.expects(:strftime).with('the time').returns('translated time') + assert_equal 'translated time', show_time(time) + end + protected def content_tag(tag, content, options) -- libgit2 0.21.2