rails/rails — pull request #10634 by teleological (2013-05-15 13:32:58+00:00)
Title: Maintain proleptic gregorian in Time#advance

If Time is assumed to represent a gregorian value (not conspicuously documented, but assumed by Time#to_date in Ruby > 1.8), Time#advance should return a value which is also gregorian. Currently, that is not invariably the case:

Time.utc(1582, 10, 15).advance(:days => -1) # => 1582-10-04 00:00:00 UTC

If a resulting Time object with implicit julian date is used in calculations with Time objects with implicit gregorian dates, hijinks ensue:

t = Time.utc(1582, 10, 15)
distance_of_time_in_words(t - t.advance(:days => -1)) # => "11 days"

I'd be glad to backport this fix. In that case ActiveSupport's Time#to_date (for Ruby < 1.9) should also be amended to specify proleptic gregorian for consistent behavior with Ruby 1.9.