diff options
author | Etienne Massip <etienne.massip@gmail.com> | 2012-06-16 21:45:47 +0000 |
---|---|---|
committer | Etienne Massip <etienne.massip@gmail.com> | 2012-06-16 21:45:47 +0000 |
commit | dbdc9b9da7564eafd9d74aa9d664642193d9791d (patch) | |
tree | feae1f5b26478f3a8fe847c6515e48ba1ae552ff /lib/redmine | |
parent | 2c07b478bb1e2954c44d9def732202a8edea9837 (diff) | |
download | redmine-dbdc9b9da7564eafd9d74aa9d664642193d9791d.tar.gz redmine-dbdc9b9da7564eafd9d74aa9d664642193d9791d.zip |
Display dates using user's locale if available (#2190).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9838 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r-- | lib/redmine/i18n.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index a377d408c..fade9a9ae 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -37,16 +37,21 @@ module Redmine def format_date(date) return nil unless date - Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format) + 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 def format_time(time, include_date = true) 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) - (include_date ? "#{format_date(local)} " : "") + - (Setting.time_format.blank? ? ::I18n.l(local, :format => :time) : local.strftime(Setting.time_format)) + (include_date ? "#{format_date(local)} " : "") + ::I18n.l(local, options) end def day_name(day) |