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)
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|
<h3><%= day_name(day.cwday) %> <%= day.day %></h3>
<ul>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| %>
- <li><p><%= e.event_datetime.strftime("%H:%M") %> <%= link_to truncate(e.event_title, 100), e.event_url %><br />
+ <li><p><%= format_time(e.event_datetime, false) %> <%= link_to truncate(e.event_title, 100), e.event_url %><br />
<% unless e.event_description.blank? %><em><%= truncate(e.event_description, 500) %></em><br /><% end %>
<span class="author"><%= e.event_author if e.respond_to?(:event_author) %></span></p></li>
<% end %>
<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
<p><label><%= l(:setting_date_format) %></label>
-<%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '0'], ['ISO 8601 (YYYY-MM-DD)', '1']], Setting.date_format) %></p>
+<%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '']] + Setting::DATE_FORMATS.collect {|f| [Date.today.strftime(f), f]}, Setting.date_format) %></p>
+
+<p><label><%= l(:setting_time_format) %></label>
+<%= select_tag 'settings[time_format]', options_for_select( [[l(:label_language_based), '']] + Setting::TIME_FORMATS.collect {|f| [Time.now.strftime(f), f]}, Setting.time_format) %></p>
<p><label><%= l(:setting_attachment_max_size) %></label>
<%= text_field_tag 'settings[attachment_max_size]', Setting.attachment_max_size, :size => 6 %> KB</p>
format: int
default: 0
# date format
-# 0: language based
-# 1: ISO format
date_format:
- format: int
- default: 0
+ default: ''
+time_format:
+ default: ''
cross_project_issue_relations:
default: 0
notified_events:
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
setting_commit_fix_keywords: Fixing keywords
setting_autologin: Autologin
setting_date_format: Date format
+setting_time_format: Time format
setting_cross_project_issue_relations: Allow cross-project issue relations
setting_issue_list_default_columns: Default columns displayed on the issue list
setting_repositories_encodings: Repositories encodings
label_week: Week
label_date_from: From
label_date_to: To
-label_language_based: Language based
+label_language_based: Based on user's language
label_sort_by: Sort by %s
label_send_test_email: Send a test email
label_feeds_access_key_created_on: RSS access key created %s ago
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
setting_commit_fix_keywords: Mot-clés de résolution
setting_autologin: Autologin
setting_date_format: Format de date
+setting_time_format: Format d'heure
setting_cross_project_issue_relations: Autoriser les relations entre demandes de différents projets
setting_issue_list_default_columns: Colonnes affichées par défaut sur la liste des demandes
setting_repositories_encodings: Encodages des dépôts
label_week: Semaine
label_date_from: Du
label_date_to: Au
-label_language_based: Basé sur la langue
+label_language_based: Basé sur la langue de l'utilisateur
label_sort_by: Trier par %s
label_send_test_email: Envoyer un email de test
label_feeds_access_key_created_on: Clé d'accès RSS créée il y a %s
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
setting_protocol: Protocol
mail_body_account_information: Your Redmine account information
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Twoje konto w Redmine
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information\r
setting_protocol: Protocol\r
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"\r
+setting_time_format: Time format\r
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
general_fmt_age: %d an
general_fmt_age_plural: %d ani
-general_fmt_date: %%m/%%d/%%A
-general_fmt_datetime: %%m/%%d/%%A %%Z:%%L %%p
-general_fmt_datetime_short: %%b %%d, %%Z:%%L %%p
-general_fmt_time: %%Z:%%L %%p
+general_fmt_date: %%m/%%d/%%Y
+general_fmt_datetime: %%m/%%d/%%Y %%I:%%M %%p
+general_fmt_datetime_short: %%b %%d, %%I:%%M %%p
+general_fmt_time: %%I:%%M %%p
general_text_No: 'Nu'
general_text_Yes: 'Da'
general_text_no: 'nu'
notice_email_error: Eroare in trimiterea e-mailului (%s)
notice_feeds_access_key_reseted: Parola de acces RSS a fost resetat.
-mail_subject_lost_password: Parola clair.ro|PM
+mail_subject_lost_password: Your Redmine password
mail_body_lost_password: 'To change your Redmine password, click on the following link:'
-mail_subject_register: Activare cont clair.ro|PM
+mail_subject_register: Redmine account activation
mail_body_register: 'To activate your Redmine account, click on the following link:'
gui_validation_error: 1 eroare
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
enumeration_issue_priorities: Приоритеты задач
enumeration_doc_categories: Категории документов
enumeration_activities: Действия (учет времени)
+setting_time_format: Time format
button_copy: Copy
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
mail_body_account_information: Your Redmine account information
setting_protocol: Protocol
label_user_mail_no_self_notified: "I don't want to be notified of changes that I make myself"
+setting_time_format: Time format
text = "{{hello_world}}"
assert textilizable(text).match(/Hello world!/)
end
+
+ def test_date_format_default
+ today = Date.today
+ Setting.date_format = ''
+ assert_equal l_date(today), format_date(today)
+ end
+
+ def test_date_format
+ today = Date.today
+ Setting.date_format = '%d %m %Y'
+ assert_equal today.strftime('%d %m %Y'), format_date(today)
+ end
+
+ def test_time_format_default
+ now = Time.now
+ Setting.date_format = ''
+ Setting.time_format = ''
+ assert_equal l_datetime(now), format_time(now)
+ assert_equal l_time(now), format_time(now, false)
+ end
+
+ def test_time_format
+ now = Time.now
+ Setting.date_format = '%d %m %Y'
+ Setting.time_format = '%H %M'
+ assert_equal now.strftime('%d %m %Y %H %M'), format_time(now)
+ assert_equal now.strftime('%H %M'), format_time(now, false)
+ end
end