Files
psu-schedule/shared/weeks.d.ts
Zakhar Timoshenko 15851b26cd feat: Enhance session handling in timetable and UI
- Introduced session types (exams, credits, consultations, coursework defenses) with distinct icons and colors for better visibility in the UI.
- Updated PlansScreen, ScheduleScreen, and WeekGrid to display session information appropriately.
- Modified CalendarView and PlansView to include session indicators in the calendar and plans.
- Enhanced LessonCard and CompactLesson to show session details and adjust styling based on session presence.
- Added new SessionMark component for consistent session representation across Android and iOS.
- Updated server logic to handle session entries from external documents, ensuring accurate timetable representation.
- Improved date parsing to accommodate session-related dates in various formats.
- Added tests to verify session handling and date parsing functionality.
2026-10-19 20:49:13 +03:00

86 lines
2.4 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 const DATE_LIST: RegExp;
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;