Commit 88f677d118a841b7ba1247309ecdd6bfcb8ff0fb

Authored by AntonioTerceiro
1 parent 438bff7e

ActionItem166: adding help to format date and time


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1523 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/application_helper.rb
... ... @@ -394,4 +394,12 @@ module ApplicationHelper
394 394  
395 395 end
396 396  
  397 + def show_date(date)
  398 + date.strftime(_('%d %B %Y'))
  399 + end
  400 +
  401 + def show_time(time)
  402 + time.strftime(_('%d %B %Y, %H:%m'))
  403 + end
  404 +
397 405 end
... ...
test/unit/application_helper_test.rb
... ... @@ -28,6 +28,20 @@ class ApplicationHelperTest < Test::Unit::TestCase
28 28 assert_equal '', stylesheet_import('something')
29 29 end
30 30  
  31 + should 'translate date' do
  32 + date = mock
  33 + expects(:_).with('%d %B %Y').returns('the date')
  34 + date.expects(:strftime).with('the date').returns('translated date')
  35 + assert_equal 'translated date', show_date(date)
  36 + end
  37 +
  38 + should 'translate time' do
  39 + time = mock
  40 + expects(:_).with('%d %B %Y, %H:%m').returns('the time')
  41 + time.expects(:strftime).with('the time').returns('translated time')
  42 + assert_equal 'translated time', show_time(time)
  43 + end
  44 +
31 45 protected
32 46  
33 47 def content_tag(tag, content, options)
... ...