rubyspec/rubyspec — pull request #215 by teleological (2013-05-15 21:51:01+00:00)
Title: Specs for Time#to_date (Ruby 1.9), Time.(gm|utc)

Added specifications for Ruby 1.9 Time#date, covering conversion rules per clock time and time zone and for Time values on either side of the Julian-Gregorian boundary, and verifying that the returned Date object is configured with the default calendar reform day. All specs pass on MRI 1.9 - 2.0, but there are failures for pre-Gregorian reform dates on JRuby 1.73 and Rubinius 2.0rc1 (RBXOPT=-X19).

There's a private Time#to_date method in Ruby 1.8, but it is evidently not fully compliant with the behavior of Ruby 1.9 Time#date. There was an inconclusive effort to publicize it as early as 1.8.6, and ActiveSupport core extensions do publicize the private method and make use of it in methods like Time#advance. Perhaps it's worth testing, too?

Although I couldn't find documentation on how Time constructors are expected to interpret pre-Gregorian reform dates, MRI 1.8 - 2.0 all use the proleptic Gregorian calendar for such dates. I added additional specs to confirm this behavior. These specs pass on JRuby 1.7.3 but fail under Rubinius 2.0rc1 for pre-Gregorian reform dates.