fix scenario when goBackwards is true + start is a number

pull/489/head
Aditya Thakral 8 months ago
parent eacb858faa
commit ec8b766aba
  1. 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…
Cancel
Save