AI Implementation feature(859): Admin Area General Settings and Categories (#21)

This commit was merged in pull request #21.
This commit is contained in:
2026-07-22 11:45:23 +00:00
parent de527ec6d6
commit c9e8dfc611
34 changed files with 7349 additions and 62 deletions
@@ -0,0 +1,39 @@
export type EventDerivedState = 'running' | 'countdown' | 'stopped' | 'unconfigured';
export function deriveEventState(start: string, end: string): EventDerivedState {
if (!start || !end) return 'unconfigured';
const s = Date.parse(start);
const e = Date.parse(end);
if (!Number.isFinite(s) || !Number.isFinite(e)) return 'unconfigured';
const now = Date.now();
if (now < s) return 'countdown';
if (now >= s && now < e) return 'running';
return 'stopped';
}
export function endAfterStartValidator(group: any): { endBeforeStart: true } | null {
const start = group.get?.('eventStartUtc')?.value;
const end = group.get?.('eventEndUtc')?.value;
if (!start || !end) return null;
const s = Date.parse(start);
const e = Date.parse(end);
if (Number.isFinite(s) && Number.isFinite(e) && e <= s) {
return { endBeforeStart: true };
}
return null;
}
export function toDatetimeLocal(iso: string): string {
if (!iso) return '';
const d = new Date(iso);
if (Number.isNaN(d.getTime())) return '';
const pad = (n: number) => String(n).padStart(2, '0');
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`;
}
export function toIsoUtc(local: string): string {
if (!local) return '';
const d = new Date(local);
if (Number.isNaN(d.getTime())) return local;
return d.toISOString();
}