mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-01 03:57:15 +00:00
Don't use current user locale to format dates (#19039).
git-svn-id: http://svn.redmine.org/redmine/trunk@13978 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e622ce6691
commit
4a6b784d14
@ -56,7 +56,6 @@ module Redmine
|
||||
return nil unless date
|
||||
options = {}
|
||||
options[:format] = Setting.date_format unless Setting.date_format.blank?
|
||||
options[:locale] = User.current.language unless User.current.language.blank?
|
||||
::I18n.l(date.to_date, options)
|
||||
end
|
||||
|
||||
@ -64,7 +63,6 @@ module Redmine
|
||||
return nil unless time
|
||||
options = {}
|
||||
options[:format] = (Setting.time_format.blank? ? :time : Setting.time_format)
|
||||
options[:locale] = User.current.language unless User.current.language.blank?
|
||||
time = time.to_time if time.is_a?(String)
|
||||
zone = User.current.time_zone
|
||||
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
|
||||
|
||||
@ -45,15 +45,11 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_date_format_default_with_user_locale
|
||||
def test_date_format_with_month_name_should_translate_with_current_locale
|
||||
set_language_if_valid 'es'
|
||||
today = now = Time.parse('2011-02-20 14:00:00')
|
||||
date = Date.parse('2011-02-20 14:00:00')
|
||||
with_settings :date_format => '%d %B %Y' do
|
||||
User.current.language = 'fr'
|
||||
s1 = "20 f\xc3\xa9vrier 2011".force_encoding("UTF-8")
|
||||
assert_equal s1, format_date(today)
|
||||
User.current.language = nil
|
||||
assert_equal '20 Febrero 2011', format_date(today)
|
||||
assert_equal '20 Febrero 2011', format_date(date)
|
||||
end
|
||||
end
|
||||
|
||||
@ -118,22 +114,6 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_time_format_default_with_user_locale
|
||||
set_language_if_valid 'en'
|
||||
User.current.language = 'fr'
|
||||
now = Time.parse('2011-02-20 15:45:22')
|
||||
with_settings :time_format => '' do
|
||||
with_settings :date_format => '' do
|
||||
assert_equal '20/02/2011 15:45', format_time(now)
|
||||
assert_equal '15:45', format_time(now, false)
|
||||
end
|
||||
with_settings :date_format => '%Y-%m-%d' do
|
||||
assert_equal '2011-02-20 15:45', format_time(now)
|
||||
assert_equal '15:45', format_time(now, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_utc_time_format
|
||||
set_language_if_valid 'en'
|
||||
now = Time.now
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user