From 5a8b481f717470b952ac7eb890f260ea98428153 Mon Sep 17 00:00:00 2001 From: Michael Curtis Date: Tue, 10 Mar 2009 12:14:54 -0500 Subject: Time.local instances: Adding 24.hours across the DST boundary adds 24 hours instead of one day [#2066 state:resolved] --- .../lib/active_support/core_ext/time/calculations.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'activesupport/lib/active_support/core_ext/time') 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 -- cgit v1.2.3