implement hook to return resolved "24hour" | "12hour" string

delegate to existing use24HourTime(), which correctly detects the browser's locale preference via Intl.DateTimeFormat
This commit is contained in:
Josh Hawkins 2026-03-29 13:45:48 -05:00
parent f44f485f48
commit 80d8d284d4

View File

@ -84,6 +84,18 @@ export function use24HourTime(config: FrigateConfig | undefined) {
}, [config, localeUses24HourTime]);
}
/**
* Returns the resolved time format key ("24hour" | "12hour") based on config
* and browser locale. Use this instead of checking config.ui.time_format directly
* to correctly handle the "browser" setting.
*/
export function useTimeFormat(
config: FrigateConfig | undefined,
): "24hour" | "12hour" {
const is24Hour = use24HourTime(config);
return is24Hour ? "24hour" : "12hour";
}
export function useFormattedHour(
config: FrigateConfig | undefined,
time: string, // hour is assumed to be in 24 hour format per the Date object