DayPeriod constructor
A class that implements a period type of a day.
Implementation
DayPeriod({required super.start, required super.end})
: assert(
end.difference(start) < const Duration(days: 1),
'The difference between start and end must be 23 hours, 59 minutes, '
'59 seconds, 999 milliseconds and 999 microseconds',
) {
const microsecond = Duration(microseconds: 1);
if (!start.isAtSameDayAs(end) ||
end.add(microsecond).isAtSameDayAs(start)) {
throw ArgumentError.value(
end,
'end',
'End must be at the same day as start and must be the last microsecond '
'of the day',
);
}
}