fix permissions and teacher attendance workflows

This commit is contained in:
2026-07-10 20:40:52 +08:00
parent 247879f276
commit 8ed1682b90
95 changed files with 4745 additions and 1237 deletions

View File

@@ -0,0 +1,15 @@
const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
const ISO_DATE_PREFIX_PATTERN = /^(\d{4}-\d{2}-\d{2})T/;
export function normalizeDateOnly(value?: string | null): string | null | undefined {
if (value == null || value === '') return value;
if (DATE_ONLY_PATTERN.test(value)) return value;
const isoPrefix = ISO_DATE_PREFIX_PATTERN.exec(value)?.[1];
if (isoPrefix) {
const date = new Date(value);
if (!Number.isNaN(date.getTime())) return date.toISOString().slice(0, 10);
}
throw new Error(`无效日期格式: ${value}`);
}