Merge pull request #640 from movermeyer/movermeyer/date_meridian_indicators
Add support for meridian indicators on `Date` objects
This commit is contained in:
commit
1d886eaf95
|
@ -282,8 +282,8 @@ module I18n
|
|||
when '%^b' then I18n.t!(:"date.abbr_month_names", :locale => locale, :format => format)[object.mon].upcase
|
||||
when '%B' then I18n.t!(:"date.month_names", :locale => locale, :format => format)[object.mon]
|
||||
when '%^B' then I18n.t!(:"date.month_names", :locale => locale, :format => format)[object.mon].upcase
|
||||
when '%p' then I18n.t!(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).upcase if object.respond_to? :hour
|
||||
when '%P' then I18n.t!(:"time.#{object.hour < 12 ? :am : :pm}", :locale => locale, :format => format).downcase if object.respond_to? :hour
|
||||
when '%p' then I18n.t!(:"time.#{(object.respond_to?(:hour) ? object.hour : 0) < 12 ? :am : :pm}", :locale => locale, :format => format).upcase
|
||||
when '%P' then I18n.t!(:"time.#{(object.respond_to?(:hour) ? object.hour : 0) < 12 ? :am : :pm}", :locale => locale, :format => format).downcase
|
||||
end
|
||||
end
|
||||
rescue MissingTranslationData => e
|
||||
|
|
|
@ -34,6 +34,11 @@ module I18n
|
|||
assert_equal 'Sa', I18n.l(@date, :format => '%a', :locale => :de)
|
||||
end
|
||||
|
||||
test "localize Date: given an meridian indicator format it returns the correct meridian indicator" do
|
||||
assert_equal 'AM', I18n.l(@date, :format => '%p', :locale => :de)
|
||||
assert_equal 'am', I18n.l(@date, :format => '%P', :locale => :de)
|
||||
end
|
||||
|
||||
test "localize Date: given an abbreviated and uppercased day name format it returns the correct abbreviated day name in upcase" do
|
||||
assert_equal 'sa'.upcase, I18n.l(@date, :format => '%^a', :locale => :de)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue