MCPcopy
hub / github.com/date-fns/date-fns / tzName

Function tzName

pkgs/tz/src/tzName/index.ts:29–44  ·  view source on GitHub ↗
(
  timeZone: string,
  date: Date,
  format: TZNameFormat = "long",
)

Source from the content-addressed store, hash-verified

27 * @returns Time zone name (e.g. "Singapore Standard Time")
28 */
29export function tzName(
30 timeZone: string,
31 date: Date,
32 format: TZNameFormat = "long",
33): string {
34 return new Intl.DateTimeFormat("en-US", {
35 // Enforces engine to render the time. Without the option JavaScriptCore omits it.
36 hour: "numeric",
37 timeZone: timeZone,
38 timeZoneName: format,
39 })
40 .format(date)
41 .split(/\s/g) // Format.JS uses non-breaking spaces
42 .slice(2) // Skip the hour and AM/PM parts
43 .join(" ");
44}

Callers 2

toTimeStringMethod · 0.90
tests.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected