UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.91 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{strict as t}from"../core/jsonMap.js";import{beforeLocaleChange as e,getLocaleLanguage as o,normalizeLocale as n}from"./locale.js";import{unknown as r,utc as a,system as m,systemTimeZone as h}from"../time/constants.js";import{shortTimeZoneName as i}from"../time/timeZoneUtils.js";import{DateTime as s}from"luxon";const l={dateStyle:void 0,year:void 0,month:void 0,day:void 0,weekday:void 0},y={timeStyle:void 0,hour12:void 0,hourCycle:void 0,hour:void 0,minute:void 0,second:void 0},d={timeZone:a},g={year:"numeric",month:"numeric",day:"numeric"},u={year:"numeric",month:"long",day:"numeric"},c={year:"numeric",month:"short",day:"numeric"},f={year:"numeric",month:"long",weekday:"long",day:"numeric"},D={hour:"numeric",minute:"numeric"},T={...D,second:"numeric"},S={hourCycle:"h23"},L={...D,...S},v={...T,...S},M={"short-date":g,"short-date-short-time":{...g,...D},"short-date-short-time-24":{...g,...L},"short-date-long-time":{...g,...T},"short-date-long-time-24":{...g,...v},"short-date-le":g,"short-date-le-short-time":{...g,...D},"short-date-le-short-time-24":{...g,...L},"short-date-le-long-time":{...g,...T},"short-date-le-long-time-24":{...g,...v},"long-month-day-year":u,"long-month-day-year-short-time":{...u,...D},"long-month-day-year-short-time-24":{...u,...L},"long-month-day-year-long-time":{...u,...T},"long-month-day-year-long-time-24":{...u,...v},"day-short-month-year":c,"day-short-month-year-short-time":{...c,...D},"day-short-month-year-short-time-24":{...c,...L},"day-short-month-year-long-time":{...c,...T},"day-short-month-year-long-time-24":{...c,...v},"long-date":f,"long-date-short-time":{...f,...D},"long-date-short-time-24":{...f,...L},"long-date-long-time":{...f,...T},"long-date-long-time-24":{...f,...v},"long-month-year":{month:"long",year:"numeric"},"short-month-year":{month:"short",year:"numeric"},year:{year:"numeric"},"short-time":D,"long-time":T},w=t()({shortDate:"short-date",shortDateShortTime:"short-date-short-time",shortDateShortTime24:"short-date-short-time-24",shortDateLongTime:"short-date-long-time",shortDateLongTime24:"short-date-long-time-24",shortDateLE:"short-date-le",shortDateLEShortTime:"short-date-le-short-time",shortDateLEShortTime24:"short-date-le-short-time-24",shortDateLELongTime:"short-date-le-long-time",shortDateLELongTime24:"short-date-le-long-time-24",longMonthDayYear:"long-month-day-year",longMonthDayYearShortTime:"long-month-day-year-short-time",longMonthDayYearShortTime24:"long-month-day-year-short-time-24",longMonthDayYearLongTime:"long-month-day-year-long-time",longMonthDayYearLongTime24:"long-month-day-year-long-time-24",dayShortMonthYear:"day-short-month-year",dayShortMonthYearShortTime:"day-short-month-year-short-time",dayShortMonthYearShortTime24:"day-short-month-year-short-time-24",dayShortMonthYearLongTime:"day-short-month-year-long-time",dayShortMonthYearLongTime24:"day-short-month-year-long-time-24",longDate:"long-date",longDateShortTime:"long-date-short-time",longDateShortTime24:"long-date-short-time-24",longDateLongTime:"long-date-long-time",longDateLongTime24:"long-date-long-time-24",longMonthYear:"long-month-year",shortMonthYear:"short-month-year",year:"year"}),Y={ar:"ar-u-nu-latn-ca-gregory",nn:"no-NN"},Z=new Intl.DateTimeFormat("bs",{month:"long"}).formatToParts(new Date(2025,2)),p=Z.find(({type:t})=>"month"===t)?.value.toLowerCase();function j(){const t=o();return(t&&Y[t])??n()}"mart"!==p&&(Y.bs="sr-Latn-CS");let E=new WeakMap;const k=M["short-date-short-time"],C=M["short-date"];function I(t){let e=E.get(t);if(!e){const o=j(),n=J(t.timeZone??m),r={...t,timeZone:n};e=new Intl.DateTimeFormat(o,r),E.set(t,e)}return e}function N(t){return M[t]}function F(t){const{dateStyle:e,timeStyle:o,hour12:n,year:r,month:a}=t,m={};return e?m.dateStyle=e:r&&(m.year=r,m.month=a||void 0),o&&!m.year&&(m.timeStyle=o,m.hour12="auto"===n?void 0:"always"===n),m}function b(t,e=k){return I(e).format(t)}function x(t,e=k){return b(new Date(t),{...e,...d,...y})}function P(t,e=k){return b(new Date(`1970-01-01T${t}Z`),{...e,...d,...l})}function W(t,e=k){const o=s.fromISO(t,{setZone:!0});if(!o.isValid)return t;if(e.timeZone)return b(o.toJSDate(),e);const n=0===o.offset?a:e.timeZone,r={...e,timeZone:n};return o.toLocaleString(r,{locale:j()})}function J(t){switch(t){case m:return h;case r:return a;default:return t}}function O(t,e){return new Intl.DateTimeFormat(j(),e).formatToParts(t)}function U(t,e=new Date){return O(e,{timeZone:t,timeZoneName:i}).find(({type:t})=>"timeZoneName"===t)?.value}e(()=>{E=new WeakMap});export{N as convertDateFormatToIntlOptions,F as convertDateTimeFieldFormatToIntlOptions,w as dateFormatJSONMap,k as defaultFormatterOptions,C as defaultFormatterOptionsNoTime,b as formatDate,x as formatDateOnly,P as formatTimeOnly,W as formatTimestamp,I as getDateTimeFormatter,U as getShortOffsetTimeZoneSuffix,J as resolveTimeZone};