1
0

chore: Archive v1 and v2
Remote Deploy / deploy (push) Successful in 1m31s

This commit is contained in:
2026-05-06 17:23:38 +02:00
parent 95766c62a0
commit 939633b675
5 changed files with 93 additions and 9 deletions
+78
View File
@@ -0,0 +1,78 @@
import fs from "fs"
const CLASSES: string[] = [
"A1a", "A1b", "A1c", "C1a", "C1b", "C1c", "A2", "C2a", "C2b", "C2c", "E2", "C3a", "C3b", "C3c", "E3"
];
function formatDate(date: Date): string {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
}
const EXAMPLE_SCHEDULE: (string | null)[] = [
"Verze 1 API bude ukončena",
"Prosím aktualizujte si aplikaci.",
"Po ukončení Vám nebude fungovat",
"mimořádný rozvrh.",
null,
"Pokud jste vývojář aplikace,",
"podívejte se na dokumentaci na",
"jecnarozvrh.jzitnik.dev",
null,
null
];
function getCurrentWeekMondayToFriday(referenceDate: Date = new Date()): string[] {
const date = new Date(referenceDate);
const day = date.getDay();
const diffToMonday = day === 0 ? -6 : 1 - day;
const monday = new Date(date);
monday.setDate(date.getDate() + diffToMonday);
const week: string[] = [];
for (let i = 0; i < 5; i++) {
const d = new Date(monday);
d.setDate(monday.getDate() + i);
week.push(formatDate(d));
}
return week;
}
interface ScheduleData {
schedule: Record<string, (string | null)[]>[];
props: { date: string; priprava: boolean }[];
status: { lastUpdated: string };
}
export default function generateArchivedV1_V2(): void {
const dates = getCurrentWeekMondayToFriday();
const currentDate = new Date();
const lastUpdated = currentDate.getHours().toString().padStart(2, "0") + ":" + currentDate.getMinutes().toString().padStart(2, "0");
const data: ScheduleData = {
schedule: [],
props: [],
status: {
lastUpdated
}
};
for (const date of dates) {
data.props.push({
date,
priprava: false
});
const d: Record<string, (string | null)[]> = {};
for (const cls of CLASSES) {
d[cls] = EXAMPLE_SCHEDULE;
}
data.schedule.push(d);
}
fs.writeFileSync("volume/db/v1.json", JSON.stringify(data, null, 2));
fs.writeFileSync("volume/db/v2.json", JSON.stringify(data, null, 2));
}