Revision 2387
Added by Jean-Philippe Lang over 16 years ago
sandbox/rails-2.2/lib/redmine/i18n.rb | ||
---|---|---|
27 | 27 |
|
28 | 28 |
def format_date(date) |
29 | 29 |
return nil unless date |
30 |
# "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed) |
|
31 |
@date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) |
|
32 |
date.strftime(@date_format) |
|
30 |
Setting.date_format.blank? ? ::I18n.l(date.to_date) : date.strftime(Setting.date_format) |
|
33 | 31 |
end |
34 | 32 |
|
35 | 33 |
def format_time(time, include_date = true) |
... | ... | |
37 | 35 |
time = time.to_time if time.is_a?(String) |
38 | 36 |
zone = User.current.time_zone |
39 | 37 |
local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time) |
40 |
@date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) |
|
41 |
@time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format) |
|
42 |
include_date ? local.strftime("#{@date_format} #{@time_format}") : local.strftime(@time_format) |
|
38 |
Setting.time_format.blank? ? ::I18n.l(local) : "#{format_date(time)} #{local.strftime(Setting.time_format)}" |
|
43 | 39 |
end |
44 | 40 |
|
45 | 41 |
def available_locales |
Also available in: Unified diff
Makes date and time formatting methods use I18n.