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,
|
start?: number | TermYear,
|
||||||
{ goBackwards = false, skipCurrent = false }: GetTermYearOptions = {}
|
{ goBackwards = false, skipCurrent = false }: GetTermYearOptions = {}
|
||||||
) {
|
) {
|
||||||
|
const allTerms = [...TERMS];
|
||||||
|
|
||||||
|
if (goBackwards) {
|
||||||
|
allTerms.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
const todayYear = today.getFullYear();
|
const todayYear = today.getFullYear();
|
||||||
const todayTerm = TERMS[Math.trunc(today.getMonth() / 4)];
|
const todayTerm = TERMS[Math.trunc(today.getMonth() / 4)];
|
||||||
|
@ -43,13 +49,7 @@ export function* getTermYear(
|
||||||
start ??= { term: todayTerm, year: todayYear };
|
start ??= { term: todayTerm, year: todayYear };
|
||||||
|
|
||||||
if (typeof start === "number") {
|
if (typeof start === "number") {
|
||||||
start = { term: TERMS[0], year: start };
|
start = { term: allTerms[0], year: start };
|
||||||
}
|
|
||||||
|
|
||||||
const allTerms = [...TERMS];
|
|
||||||
|
|
||||||
if (goBackwards) {
|
|
||||||
allTerms.reverse();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let currentYear = start.year;
|
let currentYear = start.year;
|
||||||
|
|
Loading…
Reference in New Issue