9 setup_time_translations
10 @time = ::Time.utc(2008, 3, 1, 6, 0)
11 @other_time = ::Time.utc(2008, 3, 1, 18, 0)
14 test "localize Time: given the short format it uses it" do
15 # TODO should be Mrz, shouldn't it?
16 assert_equal '01. Mar 06:00', I18n.l(@time, :format => :short, :locale => :de)
19 test "localize Time: given the long format it uses it" do
20 assert_equal '01. März 2008 06:00', I18n.l(@time, :format => :long, :locale => :de)
23 # TODO Seems to break on Windows because ENV['TZ'] is ignored. What's a better way to do this?
24 # def test_localize_given_the_default_format_it_uses_it
25 # assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@time, :format => :default, :locale => :de)
28 test "localize Time: given a day name format it returns the correct day name" do
29 assert_equal 'Samstag', I18n.l(@time, :format => '%A', :locale => :de)
32 test "localize Time: given an abbreviated day name format it returns the correct abbreviated day name" do
33 assert_equal 'Sa', I18n.l(@time, :format => '%a', :locale => :de)
36 test "localize Time: given a month name format it returns the correct month name" do
37 assert_equal 'März', I18n.l(@time, :format => '%B', :locale => :de)
40 test "localize Time: given an abbreviated month name format it returns the correct abbreviated month name" do
41 # TODO should be Mrz, shouldn't it?
42 assert_equal 'Mar', I18n.l(@time, :format => '%b', :locale => :de)
45 test "localize Time: given a meridian indicator format it returns the correct meridian indicator" do
46 assert_equal 'am', I18n.l(@time, :format => '%p', :locale => :de)
47 assert_equal 'pm', I18n.l(@other_time, :format => '%p', :locale => :de)
50 test "localize Time: given an unknown format it does not fail" do
51 assert_nothing_raised { I18n.l(@time, :format => '%x') }
54 test "localize Time: given a format is missing it raises I18n::MissingTranslationData" do
55 assert_raise(I18n::MissingTranslationData) { I18n.l(@time, :format => :missing) }
60 def setup_time_translations
61 I18n.backend.store_translations :de, {
64 :default => "%a, %d. %b %Y %H:%M:%S %z",
65 :short => "%d. %b %H:%M",
66 :long => "%d. %B %Y %H:%M",