Files
spatie-period/tests
dualfroz 67bae2d40e fix: return 0 length for empty periods instead of a positive count
Period::length() derived its count from diff()->days (day precision) and
abs() (hour/minute/second precision), both of which discard sign
information. For a period whose boundary exclusions push includedStart()
past includedEnd() (e.g. a single-day period with Boundaries::EXCLUDE_ALL),
the period is empty and iterating it yields zero dates, yet length()
still reported a positive number, disagreeing with iterator_count().

Add an explicit emptiness check so length() returns 0 whenever
includedStart() is after includedEnd(), matching the iterator's behaviour
across all precisions.
2026-09-06 00:58:50 +02:00
..