diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-20 15:30:41 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-04-20 15:30:41 -0700 |
commit | 3b93ca221d3a1b777bd880c18f52010cbd56c18c (patch) | |
tree | 7b49713994125de123775102eac2655d7b29b231 /activesupport/lib/active_support/core_ext | |
parent | daab53d8c0bca1114c1485d0dcc52858a264ab9e (diff) | |
parent | 46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd (diff) | |
download | rails-3b93ca221d3a1b777bd880c18f52010cbd56c18c.tar.gz rails-3b93ca221d3a1b777bd880c18f52010cbd56c18c.tar.bz2 rails-3b93ca221d3a1b777bd880c18f52010cbd56c18c.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 13 |
2 files changed, 9 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index 5c351c21c6..fa444f71b1 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -86,6 +86,7 @@ module ActiveSupport #:nodoc: def utc new_offset(0) end + alias_method :getutc, :utc # Returns true if offset == 0 def utc? diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 0bc83af709..ffbdf37789 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -88,18 +88,21 @@ module ActiveSupport #:nodoc: end # Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension - # Do not use this method in combination with x.months, use months_ago instead! def ago(seconds) self.since(-seconds) end # Returns a new Time representing the time a number of seconds since the instance time, this is basically a wrapper around - # the Numeric extension. Do not use this method in combination with x.months, use months_since instead! + # the Numeric extension. def since(seconds) - initial_dst = self.dst? ? 1 : 0 f = seconds.since(self) - final_dst = f.dst? ? 1 : 0 - (seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f + if ActiveSupport::Duration === seconds + f + else + initial_dst = self.dst? ? 1 : 0 + final_dst = f.dst? ? 1 : 0 + (seconds.abs >= 86400 && initial_dst != final_dst) ? f + (initial_dst - final_dst).hours : f + end rescue self.to_datetime.since(seconds) end |