mirror of
https://github.com/meineerde/redmine.git
synced 2025-10-17 17:01:01 +00:00
Allow strings representing dates to be passed to format_date (#6788)
This commit is contained in:
parent
db2ecd3010
commit
aac69276cc
@ -37,7 +37,8 @@ module Redmine
|
||||
|
||||
def format_date(date)
|
||||
return nil unless date
|
||||
Setting.date_format.blank? ? ::I18n.l(date.to_date, :count => date.strftime('%d')) : date.strftime(Setting.date_format)
|
||||
date = date.to_time if date.is_a?(String)
|
||||
Setting.date_format.blank? ? ::I18n.l(date, :count => date.strftime('%d')) : date.strftime(Setting.date_format)
|
||||
end
|
||||
|
||||
def format_time(time, include_date = true)
|
||||
|
||||
@ -37,6 +37,7 @@ class Redmine::I18nTest < ActiveSupport::TestCase
|
||||
today = Date.today
|
||||
Setting.date_format = '%d %m %Y'
|
||||
assert_equal today.strftime('%d %m %Y'), format_date(today)
|
||||
assert_equal today.strftime('%d %m %Y'), format_date(today.to_s)
|
||||
end
|
||||
|
||||
def test_date_and_time_for_each_language
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user