Closed rbUUbr closed 4 years ago
ruby version: 2.6.5 Code:
$ irb require 'date' puts Date.parse('-1111-2-2').year # => -1111
expected behavior: ruby throws ArgumentError due to invalid string passed real behavior: negative year returns.
Is it ok?
That's not an invalid date string, that's a perfectly valid date string for a negative year. Yes, it is OK and it is the expected behavior.
Ruby is designed with time travelling in mind.
https://www.youtube.com/watch?v=Qi7egXgYcgk
ruby version: 2.6.5 Code:
expected behavior: ruby throws ArgumentError due to invalid string passed real behavior: negative year returns.
Is it ok?