calculateStartDifference static method
Returns the period between the start of the first
period and the start
of the second
period.
If first
and second
do not overlap, the period that occurs before will
be returned.
If the first
period starts before the second
period, the period will
be from the start of the first
period to the start of the second
period.
If the first
period starts after the second
period, the period will be
from the start of the second
period to the start of the first
period.
If both periods start at the same time, null
will be returned.
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);
} else if (first.startsAfter(second.start)) {
return Period(start: second.start, end: first.start);
}
} else {
if (first.occursBefore(second)) return first;
return second;
}
return null;
}