From: Jean-Philippe Lang Date: Fri, 16 Nov 2007 20:26:36 +0000 (+0000) Subject: Added a couple of new formats for the 'date format' setting. X-Git-Tag: 0.6.1~59 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e4ce95c3a18496e8bc20787331d8f11c6b6b6e25;p=redmine.git Added a couple of new formats for the 'date format' setting. Added a 'time format' setting. git-svn-id: http://redmine.rubyforge.org/svn/trunk@905 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c03f073c1..e9ea74e2d 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 1c953f4c8..4d4cf0045 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 cc54eac95..c902d60a3 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -4,7 +4,7 @@

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