UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 1.73 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{UnknownTimeZone as e}from"../core/sql/UnknownTimeZone.js";import{system as n,unknown as o,utc as r}from"./constants.js";import{legacyTimeZoneMap as i}from"./legacyTimeZoneMap.js";import{FixedOffsetZone as s,IANAZone as c,DateTime as m}from"luxon";const u="shortOffset";function a(t){return"timeZoneIANA"in t}function f(t){return t.startsWith("UTC")}function l(t,e=!1){return{json:{read:{source:t,reader:(e,n)=>n[t]?p(n[t]):null},write:!!e&&{allowNull:!0,writer(e,n){n[t]=e?Z(e):null}}}}}function p(t,e=n){return t?a(t)?t.timeZoneIANA:w(t,e):e}function Z(t){return{timeZoneIANA:t}}function w(t,e=n){if(!t||!i.has(t.timeZone))return e;const o=i.get(t.timeZone);return f(t.timeZone)||t.respectsDaylightSaving?o:h(o)}function h(t){const e=m.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${s.instance(-n).formatOffset(0,"narrow")}`}function d(t,e,n,i,s){if(e&&"date"===s)return{timeZone:r,timeZoneName:void 0};const c=i.hour,m=n===o;return{timeZone:m?"timestamp-offset"===s?void 0:t??r:n,timeZoneName:m&&c?u:void 0}}function g(t){const e=new Set(["etc/utc","etc/gmt","gmt"]),r=new Set(Intl.supportedValuesOf("timeZone").map(t=>t.toLowerCase()));return t===n||t===o||e.has(t.toLowerCase())||r.has(t.toLowerCase())}const A=new Map;function C(n){return n===o?e.instance:n===r||"Etc/UTC"===n?s.utcInstance:t(A,n,()=>c.create(n))}export{w as convertLegacyTimeZone,p as fromTimeReference,C as getLuxonTimeZone,d as getTimeZoneFormattingOptions,g as isTimeZoneValid,u as shortTimeZoneName,l as timeZoneProperty,Z as toTimeReference};