Changeset 8699
- Timestamp:
- 01/23/08 02:53:29 (8 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r8698 r8699 1 1 *SVN* 2 3 * Refactor Time and DateTime #to_formatted_s: use ternary instead of nested if/else [Geoff Buesing] 2 4 3 5 * Adding Time and DateTime #formatted_offset, for outputting +HH:MM utc offset strings with cross-platform consistency [Geoff Buesing] trunk/activesupport/lib/active_support/core_ext/date_time/conversions.rb
r8698 r8699 42 42 # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } 43 43 def to_formatted_s(format = :default) 44 if formatter = ::Time::DATE_FORMATS[format] 45 if formatter.respond_to?(:call) 46 formatter.call(self).to_s 47 else 48 strftime(formatter) 49 end 50 else 51 to_datetime_default_s 52 end 44 return to_default_s unless formatter = ::Time::DATE_FORMATS[format] 45 formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) 53 46 end 54 47 trunk/activesupport/lib/active_support/core_ext/time/conversions.rb
r8698 r8699 46 46 # Time::DATE_FORMATS[:short_ordinal] = lambda { |time| time.strftime("%B #{time.day.ordinalize}") } 47 47 def to_formatted_s(format = :default) 48 if formatter = DATE_FORMATS[format] 49 if formatter.respond_to?(:call) 50 formatter.call(self).to_s 51 else 52 strftime(formatter) 53 end 54 else 55 to_default_s 56 end 48 return to_default_s unless formatter = DATE_FORMATS[format] 49 formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) 57 50 end 58 51