aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-04-20 15:30:41 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-04-20 15:30:41 -0700
commit3b93ca221d3a1b777bd880c18f52010cbd56c18c (patch)
tree7b49713994125de123775102eac2655d7b29b231 /activesupport/lib/active_support/core_ext
parentdaab53d8c0bca1114c1485d0dcc52858a264ab9e (diff)
parent46ab7422d9ebac0d529f71a3a7c2feaf0b9d5dbd (diff)
downloadrails-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.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb13
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