calculateEndDifference static method
Returns the period between the end of the first
period and the end
of the second
period.
If first
and second
overlap:
- If the
first
period ends after thesecond
period, the period will be from the end of thesecond
period to the end of thefirst
period. - If the
first
period ends before thesecond
period, the period will be from the end of thefirst
period to the end of thesecond
period. - If both periods end at the same time,
null
will be returned.
If first
and second
do not overlap, the period that occurs after will
be returned (whichever period ends last chronologically).
Implementation
static Period? calculateEndDifference(Period first, Period second) {
if (first.overlapsWith(second)) {
if (first.endsAfter(second.end)) {
return Period(start: second.end, end: first.end);
}
if (first.endsBefore(second.end)) {
return Period(start: first.end, end: second.end);
}
return null;
}
if (first.occursAfter(second)) return first;
return second;
}