mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-24 01:11:12 +00:00
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
This commit is contained in:
parent
7dca1a180b
commit
fe5ed8e6cc
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user