Actions
Bug #18274
closedTime.new initializes the date incorrectly after a leap day with a positive UTC offset
Description
With 3.1.0dev revision 30942c19c0, Time.new
can initialize the date incorrectly on the day following a leap day. The year 2000 is a leap year. 2000-03-01 00:00:00 +01:00 is considered to be 2000-02-29 00:00:00 +0100:
Time.new(2000, 3, 1, 0, 0, 0, 3600)
#=> 2000-02-29 00:00:00 +0100
Ruby 3.0.2 returns the expected result:
Time.new(2000, 3, 1, 0, 0, 0, 3600)
#=> 2000-03-01 00:00:00 +0100
UTC times and negative UTC offsets return the expected results with 3.1.0dev:
Time.utc(2000, 3, 1, 0, 0, 0)
#=> 2000-03-01 00:00:00 UTC
Time.new(2000, 3, 1, 0, 0, 0, -3600)
#=> 2000-03-01 00:00:00 -0100
Any time of day at or later than the offset also returns the expected results with 3.1.0dev:
Time.new(2020, 3, 1, 0, 59, 59, 3600)
#=> 2020-02-29 00:59:59 +0100 (incorrect)
Time.new(2020, 3, 1, 1, 0, 0, 3600)
#=> 2020-03-01 01:00:00 +0100 (expected)
Time.new(2020, 3, 1, 1, 59, 59, 7200)
#=> 2020-02-29 01:59:59 +0200 (incorrect)
Time.new(2020, 3, 1, 2, 0, 0, 7200)
#=> 2020-03-01 02:00:00 +0200 (expected)
Actions
Like0
Like0Like0