Repository navigation
Releases: rasuvaeff/duration
Releases · rasuvaeff/duration
Release list
v1.1.1
- Fix
toMillis()violating its exact-ceil contract above 2^53 microseconds (~285 years): float division lost integer precision and the result was off by ±1 ms in both directions (including round-DOWN, the exact failure the contract forbids). Now pure integer arithmetic (intdiv+ remainder), exact over the full range. - Fix
millis()— the one factory without an overflow guard: pastPHP_INT_MAXthe product silently became a float and the constructor threw an unrelatedTypeErrorinstead of the contractualInvalidArgumentException('Duration overflow: ...'). - Fix integer inputs to
seconds()/minutes()/hours()/days()losing precision through the float path once the product exceeded 2^53 (e.g.seconds(9_223_372_036_853)came out 192 µs off): integer inputs now stay in integer arithmetic end to end, with the same overflow contract asplus(). - Sidestep the PHP >= 8.4
round()regression that returns n+1 for even integer-valued floats in [2^52, 2^53) (corrupted e.g.days(86165)by +1 µs on 8.4/8.5):round()is now skipped for float products at magnitude >= 2^52, where every representable double is already integral and rounding is a mathematical no-op. - Docs: rewrite the
__toString()docblock — the unit is chosen by boundary fall-through of rounded values, not by a "displayed value >= 1" rule (fall-through can legitimately print"0.999999min"); note the deliberate half-to-even vs half-away tie asymmetry between%gand the plain-integer day rendering. Both sub-unit fall-through outputs and the half-away rounding of the float factories are now pinned by tests. - Test hardening:
toMillisproperty against an integer-ceil oracle over the full[0, PHP_INT_MAX]range;microsRoundTrip/millisRoundTripgenerators widened to the full valid ranges (the old caps were orders of magnitude below the bug zones); exactness properties and examples for the integer factories.
v1.1.0
- Check the README examples on every build with
rasuvaeff/doc-exec: the usage
block inREADME.mdandREADME.ru.mdis executed against the real
DurationAPI, andcomposer buildfails if an example stops matching it. - Migrate the property-based test suite from the frozen
rasuvaeff/property-testing2.x to the newrasuvaeff/property-testing-testoadapter (drop-in, no PHP code changes; same#[Property]attribute andGenAPI). - Persist the property regression corpus across coverage CI runs (restore before tests, env
PROPERTY_DB, save on completion of any non-cancelled run, including failed ones). - Adopt
rasuvaeff/rector-named-literalsand apply the named-argument rule to literal calls. - Raise
rasuvaeff/property-testing-testoto^0.6. - Fix
__toString(): a value that rounds up into the next unit (e.g. 999.5ms, whichtoMillis()rounds up to 1000) now falls through to that next unit ("0.9995s") instead of printing a misleading whole-number value in the wrong unit ("1000ms"). The same class of boundary artifact is now also closed at the s/min and min/h boundaries. - Fix
__toString(): day counts of 1,000,000 or more no longer render in scientific notation ("1.0e+6d"); they render as a plain integer ("1000000d"). - Fix
plus(): overflowingPHP_INT_MAXmicroseconds now throwsInvalidArgumentException('Duration overflow: ...')instead of silently promoting tofloatand letting the constructor throw an unrelatedTypeError. - Fix
seconds()/minutes()/hours()/days(): overflowingPHP_INT_MAXmicroseconds now throwsInvalidArgumentException('Duration overflow: ...')instead of silently producing a wrong (possibly zero) duration via an out-of-range float-to-int cast.
v1.0.0
- Initial release: type-safe, immutable, non-negative duration value object (
Stringable). - Stored internally as microseconds; factories
zero/micros/millis/seconds/minutes/hours/days. - Conversions:
toMicros(exact),toMillis(rounded up viaceil),toSeconds(float),toMinutes(float). - Saturating arithmetic
plus/minus; static binarymin/max. - Comparisons
compareTo/equals/isGreaterThan/isLessThan/isZero/isPositive. __toString()with fixed human-readable format (µs/ms/s/min/h/d, largest fitting unit).- Property-based tests for algebraic laws (commutativity, associativity, antisymmetry, round-trip, absorption).