This commit is contained in:
2025-12-05 12:24:38 +01:00
parent fb509607c1
commit 5a9cd28d5b
47 changed files with 5456 additions and 228 deletions

View File

@@ -0,0 +1,23 @@
import type { Weekday } from './Weekday';
import { weekdayToIndex } from './Weekday';
export class WeekdaySet {
private readonly days: Weekday[];
constructor(days: Weekday[]) {
if (!Array.isArray(days) || days.length === 0) {
throw new Error('WeekdaySet requires at least one weekday');
}
const unique = Array.from(new Set(days));
this.days = unique.sort((a, b) => weekdayToIndex(a) - weekdayToIndex(b));
}
getAll(): Weekday[] {
return [...this.days];
}
includes(day: Weekday): boolean {
return this.days.includes(day);
}
}