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
firstperiod ends after thesecondperiod, the period will be from the end of thesecondperiod to the end of thefirstperiod. - If the
firstperiod ends before thesecondperiod, the period will be from the end of thefirstperiod to the end of thesecondperiod. - If both periods end at the same time,
nullwill 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;
}