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