summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-23 08:29:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-01-23 08:29:59 +0000
commitfe5ed8e6cce9d7cd3edc514a7dc8053f7be81d03 (patch)
tree6280d8c83449ff5ab36505096485e6dc29220c07 /lib
parent7dca1a180b11a5a47a63d39db1ed513b5c316270 (diff)
downloadredmine-fe5ed8e6cce9d7cd3edc514a7dc8053f7be81d03.tar.gz
redmine-fe5ed8e6cce9d7cd3edc514a7dc8053f7be81d03.zip
Add optional user parameter to I18n#format_time to (#21421).
This is useful for mails where times should be displayed in the timezone of the recipient - not the current user causing the mail to be sent. git-svn-id: http://svn.redmine.org/redmine/trunk@15094 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/i18n.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb
index 9523f2313..f6013bcb5 100644
--- a/lib/redmine/i18n.rb
+++ b/lib/redmine/i18n.rb
@@ -71,12 +71,12 @@ module Redmine
::I18n.l(date.to_date, options)
end
- def format_time(time, include_date = true)
+ def format_time(time, include_date=true, user=User.currant)
return nil unless time
options = {}
options[:format] = (Setting.time_format.blank? ? :time : Setting.time_format)
time = time.to_time if time.is_a?(String)
- zone = User.current.time_zone
+ zone = user.time_zone
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time)
(include_date ? "#{format_date(local)} " : "") + ::I18n.l(local, options)
end