spec icon indicating copy to clipboard operation
spec copied to clipboard

Ruby 3.1: Add specs for `Time#new` `in` keyword

Open ohbarye opened this issue 3 years ago • 2 comments

Issue

Change

This pull request covers the spec below.

  • [ ] Time.new now accepts optional in: keyword argument for the timezone, as well as Time.at and Time.now, so that is now you can omit minor arguments to Time.new. [Feature #17485]

    Time.new(2021, 12, 25, in: "+07:00")
    #=> 2021-12-25 00:00:00 +0700
    

    At the same time, time component strings are converted to integers more strictly now.

    Time.new(2021, 12, 25, "+07:30")
    #=> invalid value for Integer(): "+07:30" (ArgumentError)
    

    Ruby 3.0 or earlier returned probably unexpected result 2021-12-25 07:00:00, not 2021-12-25 07:30:00 nor 2021-12-25 00:00:00 +07:30.

I used test cases for Time.at as a reference.

ohbarye avatar Oct 08 '22 15:10 ohbarye

Thank you, could you also add specs for Time.at(..., in:) and Time.now(in: ) since that's part of the same item?

eregon avatar Oct 09 '22 10:10 eregon

Sure thing. How about fe751cb and 6b1c28a?

ohbarye avatar Oct 09 '22 13:10 ohbarye

Thank you too!

ohbarye avatar Oct 15 '22 01:10 ohbarye