ruby
ruby copied to clipboard
Change Time methods to not accept 8 arguments
Before this patch, Time.utc and Time.local produced inconsistent and unexpected behaviour when 8 arguments is passed in.
For example, consider the following code
Time.utc(2000, 1, 1, 2, 3, 4, 100)
Here's the output on various Ruby implementations:
MRI: 2000-01-01 02:03:04.0001 UTC
TruffleRuby: 2000-01-01 02:03:04.0001 UTC
Opal: 2000-01-01 02:03:04 UTC
If we add an additional argument:
Time.utc(2000, 1, 1, 2, 3, 4, 100, 1)
The behaviour changes unexpectedly on MRI:
MRI: 2000-01-01 02:03:04 UTC
TruffleRuby: 2000-01-01 02:03:04.0001 UTC
Opal: 2000-01-01 02:03:04 UTC
Notice that the subseconds are lost.
This commit changes it so that 8 arguments is not accepted into the methods (i.e. an ArgumentError is raised when 8 arguments is passed in).
First, this is fundamentally a bug report. Please submit to https://bugs.ruby-lang.org. Otherwise, we may miss the report. Second, this PR prohibits 8th argument, but it causes compatibility issue. I don't think it's acceptable.
We may move our issue tracker to GitHub someday in the future. But it's a different issue.
I opened a ticket here: https://bugs.ruby-lang.org/issues/18978.
Thank you for submitting.