MCPcopy Create free account
hub / github.com/ampproject/amphtml / getTimeZoneName

Function getTimeZoneName

extensions/amp-date-display/format.js:14–29  ·  view source on GitHub ↗
(date, locale, options, format = 'long')

Source from the content-addressed store, hash-verified

12 * @private
13 */
14export function getTimeZoneName(date, locale, options, format = 'long') {
15 if (!Intl?.DateTimeFormat) {
16 return '';
17 }
18 const formatter = new Intl.DateTimeFormat(locale, {
19 timeZone: options?.timeZone,
20 timeZoneName: format,
21 });
22 const parts = formatter.formatToParts?.(date) || [];
23 for (const part of parts) {
24 if (part.type === 'timeZoneName') {
25 return part.value;
26 }
27 }
28 return '';
29}

Callers 4

BentoDateDisplayFunction · 0.90
getVariablesInUTCFunction · 0.90
getVariablesInLocal_Method · 0.90
getVariablesInUTC_Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected