start_time = booktics_time_from_gmt( $data['start_time'], $data['custom_date'] ?? 0 ); $this->end_time = booktics_time_from_gmt( $data['end_time'], $data['custom_date'] ?? 0 ); $this->day_of_week = (int) $data['week_day']; $this->custom_date = $data['custom_date'] ?? null; $this->is_holiday = $this->start_time == 0 && $this->end_time == 0; } /** * Get start time * * @return string Start time value */ public function get_start_time(): string { return $this->start_time; } /** * Get end time * * @return string End time value */ public function get_end_time(): string { return $this->end_time; } /** * Get day of week * * @return int Day of week value */ public function get_day_of_week(): int { return $this->day_of_week; } /** * Get custom date * * @return string|null Custom date value */ public function get_custom_date(): ?string { return $this->custom_date; } /** * Check if schedule entry is holiday * * @return bool True if holiday, false otherwise */ public function is_holiday(): bool { return $this->is_holiday; } /** * Compare date * * @param DateTime $date Schedule date time * * @return bool Return True if match date otherwise false */ public function matches_date( DateTime $date ): bool { $dow = intval($date->format('N')); // 1 = Monday return $this->custom_date === $date->format('Y-m-d') || ( $this->custom_date == 0 && (int)$this->day_of_week == $dow ); } }