aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2014-01-05 11:19:00 -0800
committerAndrew White <andyw@pixeltrix.co.uk>2014-01-05 11:19:00 -0800
commitffc273577a795bb41068bfc2a1bb575ec51a9712 (patch)
treea67944ccfbec8fca504f7377b911f65e1849a9d7 /activesupport/lib
parent6e867a4dfed31f364d3917dcb8d555f655a73f9e (diff)
parent0c6ddbe7b0056cb5c17d6b483c0e5a7cbd596b97 (diff)
downloadrails-ffc273577a795bb41068bfc2a1bb575ec51a9712.tar.gz
rails-ffc273577a795bb41068bfc2a1bb575ec51a9712.tar.bz2
rails-ffc273577a795bb41068bfc2a1bb575ec51a9712.zip
Merge pull request #10634 from teleological/time_advance_gregorian
Maintain proleptic gregorian in Time#advance
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 5ebafcc26e..89cd7516cd 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -91,10 +91,11 @@ class Time
end
end
- # Uses Date to provide precise Time calculations for years, months, and days.
- # The +options+ parameter takes a hash with any of these keys: <tt>:years</tt>,
- # <tt>:months</tt>, <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>,
- # <tt>:minutes</tt>, <tt>:seconds</tt>.
+ # Uses Date to provide precise Time calculations for years, months, and days
+ # according to the proleptic Gregorian calendar. The +options+ parameter
+ # takes a hash with any of these keys: <tt>:years</tt>, <tt>:months</tt>,
+ # <tt>:weeks</tt>, <tt>:days</tt>, <tt>:hours</tt>, <tt>:minutes</tt>,
+ # <tt>:seconds</tt>.
def advance(options)
unless options[:weeks].nil?
options[:weeks], partial_weeks = options[:weeks].divmod(1)
@@ -107,6 +108,7 @@ class Time
end
d = to_date.advance(options)
+ d = d.gregorian if d.julian?
time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
seconds_to_advance = \
options.fetch(:seconds, 0) +