aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/date_helper.rb
diff options
context:
space:
mode:
authorVasiliy Ermolovich <younash@gmail.com>2012-01-29 01:17:57 +0300
committerVasiliy Ermolovich <younash@gmail.com>2012-01-29 18:26:38 +0300
commit735c56d0cd7449183c1de717091b29e57b663f47 (patch)
tree50881b35a4d34a3d5c884a8df54dfa959ef7fcbf /actionpack/lib/action_view/helpers/date_helper.rb
parentfd3211ef677efe9531f38db58919a8c90d65892a (diff)
downloadrails-735c56d0cd7449183c1de717091b29e57b663f47.tar.gz
rails-735c56d0cd7449183c1de717091b29e57b663f47.tar.bz2
rails-735c56d0cd7449183c1de717091b29e57b663f47.zip
tiny refactoring
use :default option with translate method instead of condition simplify separator method
Diffstat (limited to 'actionpack/lib/action_view/helpers/date_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb18
1 files changed, 6 insertions, 12 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index ea71889519..2d37923825 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -508,7 +508,7 @@ module ActionView
# Returns a select tag with options for each of the days 1 through 31 with the current day selected.
# The <tt>date</tt> can also be substituted for a day number.
- # If you want to display days with a leading zero set the <tt>:use_two_digit_numbers</tt> key in +options+ to true.
+ # If you want to display days with a leading zero set the <tt>:use_two_digit_numbers</tt> key in +options+ to true.
# Override the field name using the <tt>:field_name</tt> option, 'day' by default.
#
# ==== Examples
@@ -854,7 +854,7 @@ module ActionView
end
def translated_date_order
- date_order = I18n.translate(:'date.order', :locale => @options[:locale]) || []
+ date_order = I18n.translate(:'date.order', :locale => @options[:locale], :default => [])
forbidden_elements = date_order - [:year, :month, :day]
if forbidden_elements.any?
@@ -990,18 +990,12 @@ module ActionView
# Returns the separator for a given datetime component.
def separator(type)
case type
- when :year
- @options[:discard_year] ? "" : @options[:date_separator]
- when :month
- @options[:discard_month] ? "" : @options[:date_separator]
- when :day
- @options[:discard_day] ? "" : @options[:date_separator]
+ when :year, :month, :day
+ @options[:"discard_#{type}"] ? "" : @options[:date_separator]
when :hour
(@options[:discard_year] && @options[:discard_day]) ? "" : @options[:datetime_separator]
- when :minute
- @options[:discard_minute] ? "" : @options[:time_separator]
- when :second
- @options[:include_seconds] ? @options[:time_separator] : ""
+ when :minute, :second
+ @options[:"discard_#{type}"] ? "" : @options[:time_separator]
end
end
end