* WIP * WIP * Type and migration fixes * Adds missing default import * Fixes import * Fixes tRPC imports in App Store * Migrate stripe helpers * WIP * Type fixes * Type fix? * WIP * WIP * Update index.ts * Fixes * Update workflow.tsx * Moved queries to lib * Moves QueryCell * Migrates MultiSelectCheckboxes * WIP * CryptoSection type fixes * WIP * Import fixes * Build fixes * Update app-providers.tsx * Build fixes * Upgrades hookform zod resolvers * Build fixes * Cleanup * Build fixes * Relocates QueryCell to ui * Moved List and SkeletonLoader * Revert QueryCell migration * Can't use QueryCell here * oops * CryptoSection cleanup * Update app-providers.tsx * Moved ee to features * ee to features/ee * Removes @calcom/ee * Adds possible feature locations * Build fixes * Migrates stripe to app-store lib * Colocates stripe imports * Update subscription.ts * Submodule sync Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
/*
|
|
* Detects navigator locale 24h time preference
|
|
* It works by checking whether hour output contains AM ('1 AM' or '01 h')
|
|
* based on the user's preferred language
|
|
* defaults to 'en-US' (12h) if no navigator language is found
|
|
*/
|
|
import { localStorage } from "@calcom/lib/webstorage";
|
|
|
|
export const isBrowserLocale24h = () => {
|
|
const localStorageTimeFormat = localStorage.getItem("timeOption.is24hClock");
|
|
// If time format is already stored in the browser then retrieve and return early
|
|
if (localStorageTimeFormat === "true") {
|
|
return true;
|
|
} else if (localStorageTimeFormat === "false") {
|
|
return false;
|
|
}
|
|
|
|
let locale = "en-US";
|
|
if (typeof window !== "undefined" && navigator) locale = window.navigator?.language;
|
|
|
|
if (!new Intl.DateTimeFormat(locale, { hour: "numeric" }).format(0).match(/M/)) {
|
|
localStorage.setItem("timeOption.is24hClock", "false");
|
|
return false;
|
|
} else {
|
|
localStorage.setItem("timeOption.is24hClock", "true");
|
|
return true;
|
|
}
|
|
};
|
|
|
|
export const detectBrowserTimeFormat = isBrowserLocale24h() ? "H:mm" : "h:mma";
|