Commit f6a6d35c
f6a6d35cbbd0Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 5 files · +1 added · ~4 modified
Description
Wire Time#localtime / #gmtime (and getlocal / getutc)
sp_time_utc already flips the is_utc presentation flag, but only utc
was mapped in codegen — t.localtime / t.gmtime hit NoMethodError.
Map gmtime / getutc to sp_time_utc, and add sp_time_localtime (is_utc =
0) for localtime / getlocal, with the analyzer typing all five as Time.
sp_Time is a value type, so (like the existing utc) these yield a new
Time rather than mutating in place: t2 = t.localtime works, a bare
t.localtime statement is a no-op on the receiver.
Closes #1107
Co-Authored-By: Claude Opus 4.8 [email protected]
Details
- Commit
- f6a6d35cbbd0
- Parent
- b726681b7180
lib/sp_time.cmodifiedView file
@@ -73,6 +73,11 @@
7373
return t;7474
}7575
76+
sp_Time sp_time_localtime(sp_Time t) {77+
t.is_utc = 0;78+
return t;79+
}80+
7681
/* is_utc selects gmtime vs localtime, off is UTC offset in seconds,7782
zbuf is the timezone abbreviation (8 bytes). mktime(gmtime(s))-s7883
is the portable offset technique (MSVCRT's %z emits the timezonelib/sp_time.hmodifiedView file
Loading diff…
spinel_analyze.rbmodifiedView file
Loading diff…
spinel_codegen.rbmodifiedView file
Loading diff…
test/time_localtime_gmtime.rbaddedView file
Loading diff…