diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-03-28 23:54:46 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-03-28 23:54:46 -0700 |
commit | fa5d5e0d16686a69d3843c30c5b8ed3a1c54f160 (patch) | |
tree | f71d48182072a04d1277fb79c41ff444ea6901c9 /activesupport | |
parent | 148da357f03100fc09569595a05a2da20231458b (diff) | |
download | rails-fa5d5e0d16686a69d3843c30c5b8ed3a1c54f160.tar.gz rails-fa5d5e0d16686a69d3843c30c5b8ed3a1c54f160.tar.bz2 rails-fa5d5e0d16686a69d3843c30c5b8ed3a1c54f160.zip |
Explicit dependency on Duration, numeric times, and date/time to_s extensions
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 1937deff7c..b8bce8379f 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -1,4 +1,10 @@ require 'tzinfo' +require 'active_support/duration' +require 'active_support/core_ext/numeric/time' +require 'active_support/core_ext/integer/time' +require 'active_support/core_ext/time/conversions' +require 'active_support/core_ext/date/conversions' +require 'active_support/core_ext/date_time/conversions' module ActiveSupport # A Time-like class that can represent a time in any time zone. Necessary because standard Ruby Time instances are @@ -148,8 +154,9 @@ module ActiveSupport # <tt>:db</tt> format outputs time in UTC; all others output time in local. # Uses TimeWithZone's +strftime+, so <tt>%Z</tt> and <tt>%z</tt> work correctly. def to_s(format = :default) - return utc.to_s(format) if format == :db - if formatter = ::Time::DATE_FORMATS[format] + if format == :db + utc.to_s(format) + elsif formatter = ::Time::DATE_FORMATS[format] formatter.respond_to?(:call) ? formatter.call(self).to_s : strftime(formatter) else "#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby 1.9 Time#to_s format |