Skip to content

Time.new: #to_int calendar fields and a full utc_offset protocol - #465

Merged
tannevaled merged 2 commits into
mainfrom
feat/cluster35
Aug 26, 2026
Merged

tannevaled merged 2 commits into
mainfrom
feat/cluster35

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Advances Time construction toward MRI 4.0.6 argument fidelity — the largest
tractable remaining core cluster (core/time/new alone +23):

  • Calendar fields (year/mon/day/hour/min/sec) accept any object with #to_int;
    a nil field falls back to its default; and the failure modes match MRI — a
    class-named no implicit conversion of X into Integer when there is no
    #to_int, can't convert X to Integer (X#to_int gives Y) when it returns a
    non-Integer, and bignum too big to convert into 'long' for an oversized one.
  • utc_offset (7th positional or the in: keyword) 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; 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
ratchet floor rises 15680 → 15750 (language+core now 15815 passing, +80, zero
regressions in a deterministic per-file sweep).

🤖 Generated with Claude Code

tannevaled and others added 2 commits August 26, 2026 18:59
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>
@tannevaled
tannevaled merged commit fd1464a into main Aug 26, 2026
7 checks passed
@tannevaled
tannevaled deleted the feat/cluster35 branch August 26, 2026 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant