fix scenario when goBackwards is true + start is a number
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
eacb858faa
commit
ec8b766aba
14
utils.ts
14
utils.ts
|
@ -36,6 +36,12 @@ export function* getTermYear(
|
|||
start?: number | TermYear,
|
||||
{ goBackwards = false, skipCurrent = false }: GetTermYearOptions = {}
|
||||
) {
|
||||
const allTerms = [...TERMS];
|
||||
|
||||
if (goBackwards) {
|
||||
allTerms.reverse();
|
||||
}
|
||||
|
||||
const today = new Date();
|
||||
const todayYear = today.getFullYear();
|
||||
const todayTerm = TERMS[Math.trunc(today.getMonth() / 4)];
|
||||
|
@ -43,13 +49,7 @@ export function* getTermYear(
|
|||
start ??= { term: todayTerm, year: todayYear };
|
||||
|
||||
if (typeof start === "number") {
|
||||
start = { term: TERMS[0], year: start };
|
||||
}
|
||||
|
||||
const allTerms = [...TERMS];
|
||||
|
||||
if (goBackwards) {
|
||||
allTerms.reverse();
|
||||
start = { term: allTerms[0], year: start };
|
||||
}
|
||||
|
||||
let currentYear = start.year;
|
||||
|
|
Loading…
Reference in New Issue