mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-26 06:34:20 +08:00
Each local-time getter (getFullYear, getMonth, getDate, getHours, ..., getTimezoneOffset) called localtime_r and walked the calendar for its own field. The thread now keeps its last local conversion, keyed by the instant and a timezone generation, so reading several local fields of one Date converts it once. The UTC walk and the second computation use integer division instead of floor. Writing or deleting process.env.TZ calls tzset and starts a new generation, so later local-time reads use the new zone, as in Node. Before, the zone the process started with stayed in effect.