@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.56 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{system as t,unknown as e,utc as n}from"./constants.js";import{legacyTimeZoneMap as o}from"./legacyTimeZoneMap.js";import{DateTime as r,FixedOffsetZone as i}from"luxon";const s="shortOffset";function m(t){return"timeZoneIANA"in t}function u(t){return t.startsWith("UTC")}function a(t,e=!1){return{json:{read:{source:t,reader:(e,n)=>n[t]?f(n[t]):null},write:!!e&&{allowNull:!0,writer(e,n){n[t]=e?c(e):null}}}}}function f(e,n=t){return e?m(e)?e.timeZoneIANA:l(e,n):n}function c(t){return{timeZoneIANA:t}}function l(e,n=t){if(!e||!o.has(e.timeZone))return n;const r=o.get(e.timeZone);return u(e.timeZone)||e.respectsDaylightSaving?r:Z(r)}function Z(t){const e=r.local().setZone(t),n=Math.min(e.set({month:1,day:1}).offset,e.set({month:5}).offset);if(0===n)return"Etc/UTC";return`Etc/GMT${i.instance(-n).formatOffset(0,"narrow")}`}function h(t,o,r,i,m){if(o&&"date"===m)return{timeZone:n,timeZoneName:void 0};const u=i.timeStyle||i.hour,a=r===e;return{timeZone:a?"timestamp-offset"===m?void 0:t??n:r,timeZoneName:a&&u?s:void 0}}function p(n){const o=new Set(["etc/utc","etc/gmt","gmt"]),r=new Set(Intl.supportedValuesOf("timeZone").map((t=>t.toLowerCase())));return n===t||n===e||o.has(n.toLowerCase())||r.has(n.toLowerCase())}export{l as convertLegacyTimeZone,f as fromTimeReference,h as getTimeZoneFormattingOptions,p as isTimeZoneValid,s as shortTimeZoneName,a as timeZoneProperty,c as toTimeReference};