Commit e589bffc
e589bffcbaedMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 4 files · +2 added · ~2 modified
Description
Wire Time#utc? / #tv_usec / #tv_nsec (and usec / nsec / tv_sec / gmt?)
These instance accessors read fields the sp_Time value already carries
(is_utc, tv_nsec, tv_sec) but had no codegen entry, so they raised
cannot resolve call to '...' on time.
- utc? / gmt? -> the is_utc presentation flag (bool, like dst?)
- usec / tv_usec -> microsecond fraction (tv_nsec / 1000)
- nsec / tv_nsec -> nanosecond fraction
- tv_sec -> whole epoch seconds (alias of to_i)
analyze types the int group alongside the existing year/hour/... group and the predicate group alongside isdst/dst?; codegen reads the struct fields directly (rc bound once so a side-effecting receiver isn't evaluated twice). Sub-second data is populated by Time.at(Float) and Time.now, so the accessors are exercised end to end without the 7-arg Time.utc(usec) constructor or Time.parse (both separate gaps).
Full suite green (706) and optcarrot checksum unchanged (59662).
Fixes #1111 Fixes #1112 Fixes #1113
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- e589bffcbaed
- Parent
- af3bc1b7787e
spinel_analyze.rbmodifiedView file
# receiver so user classes defining same-named methods still # flow through normal resolution. Local Time.new is in scope; # the fixed-offset 7-arg form is a separate Issue. if mname == "year" || mname == "mon" || mname == "month" || mname == "mday" || mname == "day" || mname == "hour" || mname == "min" || mname == "sec" || mname == "wday" || mname == "yday" || mname == "utc_offset" || mname == "gmt_offset" || mname == "gmtoff" if mname == "year" || mname == "mon" || mname == "month" || mname == "mday" || mname == "day" || mname == "hour" || mname == "min" || mname == "sec" || mname == "wday" || mname == "yday" || mname == "utc_offset" || mname == "gmt_offset" || mname == "gmtoff" || mname == "usec" || mname == "tv_usec" || mname == "nsec" || mname == "tv_nsec" || mname == "tv_sec" if recv >= 0 && infer_type(recv) == "time" return "int" end end # isdst / dst? are predicates: CRuby returns true / false, # not 0 / 1, so they infer as bool (not the int accessor group). if mname == "isdst" || mname == "dst?" # isdst / dst? and utc? / gmt? are predicates: CRuby returns # true / false, not 0 / 1, so they infer as bool (not the int # accessor group). if mname == "isdst" || mname == "dst?" || mname == "utc?" || mname == "gmt?" if recv >= 0 && infer_type(recv) == "time" return "bool" endspinel_codegen.rbmodifiedView file
Loading diff…
test/time_subsec_utc.rbaddedView file
Loading diff…
test/time_subsec_utc.rb.expectedaddedView file
Loading diff…