Repository navigation
Time.new: #to_int calendar fields and a full utc_offset protocol - #465
Merged
Merged
Conversation
Bring Time construction to MRI 4.0.6 argument fidelity: - Calendar fields (year/mon/day/hour/min/sec) accept any object with #to_int, a nil field falls back to its default, and the two failure modes match MRI — a class-named "no implicit conversion of X into Integer" when there is no #to_int, and "can't convert X to Integer (X#to_int gives Y)" when it returns a non-Integer. - The utc_offset argument (7th positional or the in: keyword) now accepts an Integer number of seconds and a String in "(+|-)HH[:MM[:SS]]", "UTC"/"Z" or single military-letter form, rejecting a magnitude of a whole day or more, and a malformed String, exactly as MRI does; a non-numeric object is a TypeError. localtime / getlocal and Time#round now share the same offset and integer coercion, so they gain the Integer-offset and #to_int forms too, and the now-unfolded parseZone / numInt helpers are removed. Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec floor rises 15680 -> 15750 (language+core now 15815 passing, +80). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances
Timeconstruction toward MRI 4.0.6 argument fidelity — the largesttractable remaining core cluster (
core/time/newalone +23):#to_int;a
nilfield falls back to its default; and the failure modes match MRI — aclass-named
no implicit conversion of X into Integerwhen there is no#to_int,can't convert X to Integer (X#to_int gives Y)when it returns anon-Integer, and
bignum too big to convert into 'long'for an oversized one.in:keyword) accepts an Integer numberof seconds and a String in
(+|-)HH[:MM[:SS]],"UTC"/"Z"or singlemilitary-letter form, rejecting a magnitude of a whole day or more, and a
malformed String, exactly as MRI; a non-numeric object is a
TypeError.localtime/getlocalandTime#roundnow share the same offset and integercoercion (so they gain the Integer-offset and
#to_intforms too), and thenow-unfolded
parseZone/numInthelpers are removed.Verified against ruby 4.0.6. Whole-package coverage stays at 100%; the ruby/spec
ratchet floor rises 15680 → 15750 (language+core now 15815 passing, +80, zero
regressions in a deterministic per-file sweep).
🤖 Generated with Claude Code