fix scenario when goBackwards is true + start is a number
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Aditya Thakral 2022-08-08 01:19:29 -07:00
parent eacb858faa
commit ec8b766aba
1 changed files with 7 additions and 7 deletions

View File

@ -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;