@@ -45,8 +45,8 module Redmine | |||
|
45 | 45 | time = time.to_time if time.is_a?(String) |
|
46 | 46 | zone = User.current.time_zone |
|
47 | 47 | local = zone ? time.in_time_zone(zone) : (time.utc? ? time.localtime : time) |
|
48 | Setting.time_format.blank? ? ::I18n.l(local, :format => (include_date ? :default : :time)) : | |
|
49 | ((include_date ? "#{format_date(time)} " : "") + "#{local.strftime(Setting.time_format)}") | |
|
48 | (include_date ? "#{format_date(local)} " : "") + | |
|
49 | (Setting.time_format.blank? ? ::I18n.l(local, :format => :time) : local.strftime(Setting.time_format)) | |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | def day_name(day) |
@@ -58,13 +58,36 class Redmine::I18nTest < ActiveSupport::TestCase | |||
|
58 | 58 | end |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | def test_time_format | |
|
62 | set_language_if_valid 'en' | |
|
63 | now = Time.parse('2011-02-20 15:45:22') | |
|
64 | with_settings :time_format => '%H:%M' do | |
|
65 | with_settings :date_format => '' do | |
|
66 | assert_equal '02/20/2011 15:45', format_time(now) | |
|
67 | assert_equal '15:45', format_time(now, false) | |
|
68 | end | |
|
69 | ||
|
70 | with_settings :date_format => '%Y-%m-%d' do | |
|
71 | assert_equal '2011-02-20 15:45', format_time(now) | |
|
72 | assert_equal '15:45', format_time(now, false) | |
|
73 | end | |
|
74 | end | |
|
75 | end | |
|
76 | ||
|
61 | 77 | def test_time_format_default |
|
62 | 78 | set_language_if_valid 'en' |
|
63 | now = Time.now | |
|
64 |
|
|
|
65 |
|
|
|
66 |
assert_equal |
|
|
67 |
assert_equal |
|
|
79 | now = Time.parse('2011-02-20 15:45:22') | |
|
80 | with_settings :time_format => '' do | |
|
81 | with_settings :date_format => '' do | |
|
82 | assert_equal '02/20/2011 03:45 pm', format_time(now) | |
|
83 | assert_equal '03:45 pm', format_time(now, false) | |
|
84 | end | |
|
85 | ||
|
86 | with_settings :date_format => '%Y-%m-%d' do | |
|
87 | assert_equal '2011-02-20 03:45 pm', format_time(now) | |
|
88 | assert_equal '03:45 pm', format_time(now, false) | |
|
89 | end | |
|
90 | end | |
|
68 | 91 | end |
|
69 | 92 | |
|
70 | 93 | def test_time_format |
General Comments 0
You need to be logged in to leave comments.
Login now