Skip to content

Commit a6e2d5e

Browse files
committed
refactor: . Extract getDatePriorityOrder()
1 parent 5f2f3a3 commit a6e2d5e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/Task/Occurrence.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ export class Occurrence {
5555
* @private
5656
*/
5757
private getReferenceDate(): Moment | null {
58+
const datesInPriorityOrder = this.getDatePriorityOrder();
59+
60+
for (const date of datesInPriorityOrder) {
61+
if (date) {
62+
return window.moment(date);
63+
}
64+
}
65+
66+
return null;
67+
}
68+
69+
private getDatePriorityOrder(): (Moment | null)[] {
5870
const datesInPriorityOrder: (Moment | null)[] = [];
5971

6072
datesInPriorityOrder.push(this.dueDate);
@@ -71,14 +83,7 @@ export class Occurrence {
7183
datesInPriorityOrder.push(this.scheduledDate);
7284
datesInPriorityOrder.push(this.startDate);
7385
}
74-
75-
for (const date of datesInPriorityOrder) {
76-
if (date) {
77-
return window.moment(date);
78-
}
79-
}
80-
81-
return null;
86+
return datesInPriorityOrder;
8287
}
8388

8489
public isIdenticalTo(other: Occurrence): boolean {

0 commit comments

Comments
 (0)