aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date_time/conversions.rb
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-01-23 02:53:29 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-01-23 02:53:29 +0000
commitfc71a07edb214a7f8c08ef69b6e6f4284761de5d (patch)
tree1a14e091271bc6ea970891ba1644f04830a280aa /activesupport/lib/active_support/core_ext/date_time/conversions.rb
parentabb24b484fcb306be17dd06a8a2d12ca5a035aeb (diff)
downloadrails-fc71a07edb214a7f8c08ef69b6e6f4284761de5d.tar.gz
rails-fc71a07edb214a7f8c08ef69b6e6f4284761de5d.tar.bz2
rails-fc71a07edb214a7f8c08ef69b6e6f4284761de5d.zip
Refactor Time and DateTime #to_formatted_s: use ternary instead of nested if/else
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8699 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date_time/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb11
1 files changed, 2 insertions, 9 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index 59d742cde3..fa49c70c90 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -41,15 +41,8 @@ module ActiveSupport #:nodoc:
# Time::DATE_FORMATS[:month_and_year] = "%B %Y"
# Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") }
def to_formatted_s(format = :default)
- if formatter = ::Time::DATE_FORMATS[format]
- if formatter.respond_to?(:call)
- formatter.call(self).to_s
- else
- strftime(formatter)
- end
- else
- to_datetime_default_s
- end
+ return to_default_s unless formatter = ::Time::DATE_FORMATS[format]
+ formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter)
end
# Returns the utc_offset as an +HH:MM formatted string. Examples: