ruby icon indicating copy to clipboard operation
ruby copied to clipboard

Change Time methods to not accept 8 arguments

Open peterzhu2118 opened this issue 2 years ago • 3 comments

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).

peterzhu2118 avatar Aug 24 '22 18:08 peterzhu2118

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.

matz avatar Aug 25 '22 09:08 matz

I opened a ticket here: https://bugs.ruby-lang.org/issues/18978.

peterzhu2118 avatar Aug 25 '22 13:08 peterzhu2118

Thank you for submitting.

matz avatar Aug 25 '22 13:08 matz