9 setup_datetime_translations
10 @datetime = ::DateTime.new(2008, 3, 1, 6)
11 @other_datetime = ::DateTime.new(2008, 3, 1, 18)
14 test "localize DateTime: 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(@datetime, :format => :short, :locale => :de)
19 test "localize DateTime: given the long format it uses it" do
20 assert_equal '01. März 2008 06:00', I18n.l(@datetime, :format => :long, :locale => :de)
23 test "localize DateTime: given the default format it uses it" do
24 # TODO should be Mrz, shouldn't it?
25 assert_equal 'Sa, 01. Mar 2008 06:00:00 +0000', I18n.l(@datetime, :format => :default, :locale => :de)
28 test "localize DateTime: given a day name format it returns the correct day name" do
29 assert_equal 'Samstag', I18n.l(@datetime, :format => '%A', :locale => :de)
32 test "localize DateTime: given an abbreviated day name format it returns the correct abbreviated day name" do
33 assert_equal 'Sa', I18n.l(@datetime, :format => '%a', :locale => :de)
36 test "localize DateTime: given a month name format it returns the correct month name" do
37 assert_equal 'März', I18n.l(@datetime, :format => '%B', :locale => :de)
40 test "localize DateTime: 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(@datetime, :format => '%b', :locale => :de)
45 test "localize DateTime: given a meridian indicator format it returns the correct meridian indicator" do
46 assert_equal 'am', I18n.l(@datetime, :format => '%p', :locale => :de)
47 assert_equal 'pm', I18n.l(@other_datetime, :format => '%p', :locale => :de)
50 test "localize DateTime: given an unknown format it does not fail" do
51 assert_nothing_raised { I18n.l(@datetime, :format => '%x') }
54 test "localize DateTime: given a format is missing it raises I18n::MissingTranslationData" do
55 assert_raise(I18n::MissingTranslationData) { I18n.l(@datetime, :format => :missing) }
60 def setup_datetime_translations
61 # time translations might have been set up in Tests::Api::Localization::Time
62 I18n.backend.store_translations :de, {
65 :default => "%a, %d. %b %Y %H:%M:%S %z",
66 :short => "%d. %b %H:%M",
67 :long => "%d. %B %Y %H:%M"