MCPcopy Create free account
hub / github.com/oboard/claude-code-rev / getLocale

Function getLocale

src/utils/formatBriefTimestamp.ts:58–77  ·  view source on GitHub ↗

* Derive a BCP 47 locale tag from POSIX env vars. * LC_ALL > LC_TIME > LANG, falls back to undefined (system default). * Converts POSIX format (en_GB.UTF-8) to BCP 47 (en-GB).

()

Source from the content-addressed store, hash-verified

56 * Converts POSIX format (en_GB.UTF-8) to BCP 47 (en-GB).
57 */
58function getLocale(): string | undefined {
59 const raw =
60 process.env.LC_ALL || process.env.LC_TIME || process.env.LANG || ''
61 if (!raw || raw === 'C' || raw === 'POSIX') {
62 return undefined
63 }
64 // Strip codeset (.UTF-8) and modifier (@euro), replace _ with -
65 const base = raw.split('.')[0]!.split('@')[0]!
66 if (!base) {
67 return undefined
68 }
69 const tag = base.replaceAll('_', '-')
70 // Validate by trying to construct an Intl locale — invalid tags throw
71 try {
72 new Intl.DateTimeFormat(tag)
73 return tag
74 } catch {
75 return undefined
76 }
77}
78
79function startOfDay(d: Date): number {
80 return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime()

Callers 1

formatBriefTimestampFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected