MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getLocale

Function getLocale

source code/utils/formatBriefTimestamp.ts:60–79  ·  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

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