85 lines
2.3 KiB
TypeScript
85 lines
2.3 KiB
TypeScript
export type WeekRange = [number, number | null];
|
|
export interface CalendarWeek {
|
|
n: number;
|
|
start: string;
|
|
end: string;
|
|
color: "white" | "green";
|
|
semester?: string;
|
|
}
|
|
export interface Semester {
|
|
id: string;
|
|
kind: "autumn" | "spring";
|
|
year: number;
|
|
label: string;
|
|
start: string;
|
|
end: string;
|
|
}
|
|
export interface Bell {
|
|
pair: number;
|
|
start: string;
|
|
end: string;
|
|
halves: [string, string][];
|
|
}
|
|
export interface AcademicCalendar {
|
|
weeks: CalendarWeek[];
|
|
semesters?: Semester[];
|
|
bells: Bell[];
|
|
source: {
|
|
weeks?: string | null;
|
|
bells?: string | null;
|
|
weeksFiles?: string[];
|
|
bellsFile?: string | null;
|
|
};
|
|
updatedAt: string | null;
|
|
stale?: boolean;
|
|
error?: string;
|
|
}
|
|
/** A calendar narrowed to the semester a schedule belongs to. */
|
|
export interface SemesterCalendar extends AcademicCalendar {
|
|
semester: Semester;
|
|
}
|
|
interface ScheduleLike {
|
|
lessons: { date: string | null }[];
|
|
period?: string;
|
|
academicYear?: string | number | null;
|
|
}
|
|
interface WeekLesson {
|
|
day: number;
|
|
date: string | null;
|
|
dates?: string[];
|
|
condition: string;
|
|
variant: "all" | "upper" | "lower";
|
|
weekRanges?: WeekRange[] | null;
|
|
}
|
|
export function parseWeekRanges(condition: string): WeekRange[] | null;
|
|
export function parseTextDates(raw: string, year: string | number): string[];
|
|
export function isoDate(time: number): string;
|
|
export function addDays(iso: string, days: number): string;
|
|
export function weekday(iso: string): number;
|
|
export function todayIso(now?: Date): string;
|
|
export function weekIndexOf(
|
|
calendar: AcademicCalendar | null | undefined,
|
|
iso: string,
|
|
): number;
|
|
export function dateInWeek(week: CalendarWeek, day: number): string | null;
|
|
export function lessonWeeks(lesson: WeekLesson, lastWeek: number): number[] | null;
|
|
export function lessonDates(
|
|
lesson: WeekLesson,
|
|
calendar: AcademicCalendar | null | undefined,
|
|
): string[] | null;
|
|
export function academicStartYear(iso: string): number;
|
|
export function assignSemesters(weeks: CalendarWeek[]): {
|
|
weeks: CalendarWeek[];
|
|
semesters: Semester[];
|
|
};
|
|
export function semesterFor(
|
|
calendar: AcademicCalendar | null | undefined,
|
|
schedule: ScheduleLike | null | undefined,
|
|
today: string,
|
|
): Semester | null;
|
|
export function semesterView(
|
|
calendar: AcademicCalendar | null | undefined,
|
|
schedule: ScheduleLike | null | undefined,
|
|
today: string,
|
|
): SemesterCalendar | null;
|