toDayRange method

  1. @useResult
DateTimeRange<DateTime> toDayRange()

The full local calendar day of this date as a DateTimeRange: startOfDay (00:00:00.000000) to endOfDay (23:59:59.999999).

Composes the existing day-bound getters so the bounds keep a single source of truth — a future change to startOfDay / endOfDay flows through here automatically. The end is the last representable instant before the next midnight (microsecond precision), deliberately NOT the millisecond- truncated ...59.999 form, so no real sub-millisecond instant of the day falls outside the range.

Edge cases / guarantees:

  • Both bounds stay on this calendar day; Feb 29, Dec 31, and Jan 1 inputs do not bleed into an adjacent day.
  • Bounds use wall-clock DateTime arithmetic, so on a DST-transition day the range's real-time DateTimeRange.duration is NOT a clean 23h59m59.999999s — it is shorter (spring-forward) or longer (fall-back) by the offset shift. This is intentional local-wall-clock semantics, not a bug.
  • The bounds are local even for a UTC receiver, because startOfDay / endOfDay build local DateTimes.

Example:

DateTime(2024, 3, 15, 10, 30).toDayRange();
// start: DateTime(2024, 3, 15), end: DateTime(2024, 3, 15, 23, 59, 59, 999, 999)

Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
DateTimeRange toDayRange() => DateTimeRange(start: startOfDay, end: endOfDay);