5 Commits
Author SHA1 Message Date
dualfroz 7ac0999a38 Describe this repository 2026-10-22 21:07:06 +02:00
dualfroz aeda5bd6bd 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-04 03:06:24 +02:00
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
dualfroz 5763d58d02 fix: return 0 from length() when excluded boundaries leave a period empty
Excluding the boundaries of a one or two unit long period pushes the
included start past the included end. diff()->days is unsigned and the
HOUR/MINUTE/SECOND branch applied abs() outright, so that backwards range
was measured as a positive distance and the unconditional +1 inflated it
further: a one day period reported 1, 2, 2 and 3 for EXCLUDE_NONE, START,
END and ALL, while iterating the same objects yielded nothing.

Return 0 up front when the included start is past the included end. This
matches what the MONTH and YEAR precisions already returned through
iterator_count(), and lets the now unreachable abs() go.
2026-09-03 14:39:22 +02:00
dualfroz 9086ebcaab fix: return 0 from length() when excluded boundaries leave a period empty
Excluding the boundaries of a one or two unit long period pushes the
included start past the included end. diff()->days is unsigned and the
HOUR/MINUTE/SECOND branch applied abs() outright, so that backwards range
was measured as a positive distance and the unconditional +1 inflated it
further: a one day period reported 1, 2, 2 and 3 for EXCLUDE_NONE, START,
END and ALL, while iterating the same objects yielded nothing.

Return 0 up front when the included start is past the included end. This
matches what the MONTH and YEAR precisions already returned through
iterator_count(), and lets the now unreachable abs() go.
2026-09-04 22:00:22 +02:00