A PHP internals RFC thread proposes adding a new `Time\Duration` class to PHP 8.6, targeting 'stopwatch' or 'egg-timer' style durations for use in timeout APIs, particularly the new Polling API. The class uses a seconds+nanoseconds internal representation (similar to Rust's and Java's Duration), supports construction from hours down, and parses ISO-8601 period strings starting with 'PT'. The RFC is intentionally minimal to meet the PHP 8.6 feature freeze deadline. Discussion covers design decisions including: why floating-point total methods were deferred (precision/rounding concerns), why the `Time` namespace was chosen over `DateTime`, whether to use `add`/`sub` vs a variadic `sum` method, and why adopting the JavaScript Temporal/temporal_rs library wholesale was rejected in favor of a PHP-idiomatic API.

31m read timeFrom externals.io
Post cover image
243 Impressions