aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/time
diff options
context:
space:
mode:
authorMichael Curtis <m.curtis@me.com>2009-03-10 12:14:54 -0500
committerGeoff Buesing <gbuesing@gmail.com>2009-03-29 16:15:44 -0500
commit5a8b481f717470b952ac7eb890f260ea98428153 (patch)
tree5d7f20143fb24dc78b64e970cb2d3bb14e754e06 /activesupport/lib/active_support/core_ext/time
parentdd2eb1ea7c34eb6496feaf7e42100f37a8dae76b (diff)
downloadrails-5a8b481f717470b952ac7eb890f260ea98428153.tar.gz
rails-5a8b481f717470b952ac7eb890f260ea98428153.tar.bz2
rails-5a8b481f717470b952ac7eb890f260ea98428153.zip
Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day [#2066 state:resolved]
Diffstat (limited to 'activesupport/lib/active_support/core_ext/time')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb14
1 files changed, 3 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 5ed750afcc..d13d0e01a7 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -116,22 +116,14 @@ module ActiveSupport #:nodoc:
seconds_to_advance == 0 ? time_advanced_by_date : time_advanced_by_date.since(seconds_to_advance)
end
- # Returns a new Time representing the time a number of seconds ago, this is basically a wrapper around the Numeric extension
+ # Returns a new Time representing the time a number of seconds ago
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.
+ # Returns a new Time representing the time a number of seconds since the instance time
def since(seconds)
- f = seconds.since(self)
- 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
+ self + seconds
rescue
self.to_datetime.since(seconds)
end