diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c03f073c..e9ea74e2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -71,15 +71,17 @@ module ApplicationHelper def format_date(date) return nil unless date - @date_format ||= (Setting.date_format.to_i == 0 ? l(:general_fmt_date) : "%Y-%m-%d") + # "Setting.date_format.size < 2" is a temporary fix (content of date_format setting changed) + @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) date.strftime(@date_format) end - def format_time(time) + def format_time(time, include_date = true) return nil unless time - @date_format_setting ||= Setting.date_format.to_i time = time.to_time if time.is_a?(String) - @date_format_setting == 0 ? l_datetime(time) : (time.strftime("%Y-%m-%d") + ' ' + l_time(time)) + @date_format ||= (Setting.date_format.blank? || Setting.date_format.size < 2 ? l(:general_fmt_date) : Setting.date_format) + @time_format ||= (Setting.time_format.blank? ? l(:general_fmt_time) : Setting.time_format) + include_date ? time.strftime("#{@date_format} #{@time_format}") : time.strftime(@time_format) end def authoring(created, author) diff --git a/app/models/setting.rb b/app/models/setting.rb index 1c953f4c..4d4cf004 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -17,6 +17,23 @@ class Setting < ActiveRecord::Base + DATE_FORMATS = [ + '%Y-%m-%d', + '%d/%m/%Y', + '%d.%m.%Y', + '%d-%m-%Y', + '%m/%d/%Y', + '%d %b %Y', + '%d %B %Y', + '%b %d, %Y', + '%B %d, %Y' + ] + + TIME_FORMATS = [ + '%H:%M', + '%I:%M %p' + ] + cattr_accessor :available_settings @@available_settings = YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) Redmine::Plugin.registered_plugins.each do |id, plugin| diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml index cc54eac9..c902d60a 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -4,7 +4,7 @@

<%= day_name(day.cwday) %> <%= day.day %>