const defaultTime = {
    hour: 8,
    minute: 30,
    period: 'AM',
};
export function parseTime(value) {
    if (!value)
        return defaultTime;
    const matches = value.trim().match(/^([0]?[1-9]|1[0-2]):(00|30)\s?(AM|PM)$/i);
    if (!matches)
        return defaultTime;
    const [, hour, minute, period] = matches;
    return {
        hour: Number(hour),
        minute: Number(minute),
        period: period.toUpperCase(),
    };
}
export function formatTime(time) {
    return `${padTimeValue(time.hour)}:${padTimeValue(time.minute)} ${time.period}`;
}
export function padTimeValue(value) {
    return value.toString().padStart(2, '0');
}
//# sourceMappingURL=time.js.map