Skip to content

Commit

Permalink
account for null alternate
Browse files Browse the repository at this point in the history
  • Loading branch information
33tm committed Aug 22, 2024
1 parent 5b31e35 commit 147410d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions shared/util/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import schedule, {SCHOOL_START, SCHOOL_END, SCHOOL_END_EXCLUSIVE, PeriodObj} fro
export const numToWeekday = (num: number) => ['S', 'M', 'T', 'W', 'R', 'F', 'A'][num];

// Account for how the weekly SELF/SH rotation aren't necessarily alternates
export function isAlternate(normal: PeriodObj[], alternate: PeriodObj[]) {
const selfShFilter = ({ n }) => !['S', 'H'].includes(n);
export function isAlternate(normal: PeriodObj[], alternate: PeriodObj[] | null) {
if (!alternate) return true
const selfShFilter = ({ n }: { n: PeriodObj["n"] }) => !['S', 'H'].includes(n);
return JSON.stringify(normal.filter(selfShFilter)) !== JSON.stringify(alternate.filter(selfShFilter));
}

Expand Down

0 comments on commit 147410d

Please sign in to comment.