import { RaceTimeOfDay } from './RaceTimeOfDay'; import { LeagueTimezone } from './LeagueTimezone'; import type { RecurrenceStrategy } from './RecurrenceStrategy'; export class SeasonSchedule { readonly startDate: Date; readonly timeOfDay: RaceTimeOfDay; readonly timezone: LeagueTimezone; readonly recurrence: RecurrenceStrategy; readonly plannedRounds: number; constructor(params: { startDate: Date; timeOfDay: RaceTimeOfDay; timezone: LeagueTimezone; recurrence: RecurrenceStrategy; plannedRounds: number; }) { if (!(params.startDate instanceof Date) || Number.isNaN(params.startDate.getTime())) { throw new Error('SeasonSchedule.startDate must be a valid Date'); } if (!Number.isInteger(params.plannedRounds) || params.plannedRounds <= 0) { throw new Error('SeasonSchedule.plannedRounds must be a positive integer'); } this.startDate = new Date( params.startDate.getFullYear(), params.startDate.getMonth(), params.startDate.getDate(), ); this.timeOfDay = params.timeOfDay; this.timezone = params.timezone; this.recurrence = params.recurrence; this.plannedRounds = params.plannedRounds; } }