Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
mudeer-web-backup30April26
/
src
/
lib
/
Filename :
time-options.ts
back
Copy
/** * Generate time options with 15-minute intervals (AM/PM format). * Used by register and settings for start/end time dropdowns. */ export function generateTimeOptions(): string[] { const times: string[] = [] for (let hour = 0; hour < 24; hour++) { for (let minute = 0; minute < 60; minute += 15) { const date = new Date() date.setHours(hour, minute, 0, 0) const timeString = date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }) times.push(timeString) } } return times } /** * Normalize a stored time string (e.g. "9:0 AM") to match an option (e.g. "9:00 AM"). * Returns the matching option, or the original stored value if it's "off" or already in options. */ export function normalizeTimeOption(stored: string, options: string[]): string { if (!stored) return stored if (stored === 'off' || options.includes(stored)) return stored const match = stored.match(/^(\d{1,2}):(\d{1,2})\s*(AM|PM)$/i) if (!match) return stored const [, hour, minute, period] = match const normalized = `${parseInt(hour!, 10)}:${minute!.padStart(2, '0')} ${period!.toUpperCase()}` return options.includes(normalized) ? normalized : stored }