UNPKG

@anoki/fse-marche-ui

Version:

FSE UI components library

3 lines (2 loc) 1.8 kB
"use strict";const c=require("./index.cjs124.js"),v=require("./index.cjs133.js"),g=new Map;function w(a){let e=g.get(a);return e===void 0&&(e=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:a,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"}),g.set(a,e)),e}const C={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function D(a,e){const t=a.format(e).replace(/\u200E/g,""),r=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(t),[,n,i,o,s,f,u,l]=r;return[o,n,i,s,f,u,l]}function N(a,e){const t=a.formatToParts(e),r=[];for(let n=0;n<t.length;n++){const{type:i,value:o}=t[n],s=C[i];i==="era"?r[s]=o:c.isUndefined(s)||(r[s]=parseInt(o,10))}return r}const p=new Map;class d extends v{static create(e){let t=p.get(e);return t===void 0&&p.set(e,t=new d(e)),t}static resetCache(){p.clear(),g.clear()}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=d.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:r}){return c.parseZoneInfo(e,t,r,this.name)}formatOffset(e,t){return c.formatOffset(this.offset(e),t)}offset(e){if(!this.valid)return NaN;const t=new Date(e);if(isNaN(t))return NaN;const r=w(this.name);let[n,i,o,s,f,u,l]=r.formatToParts?N(r,t):D(r,t);s==="BC"&&(n=-Math.abs(n)+1);const y=f===24?0:f,T=c.objToLocalTS({year:n,month:i,day:o,hour:y,minute:u,second:l,millisecond:0});let h=+t;const m=h%1e3;return h-=m>=0?m:1e3+m,(T-h)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}}module.exports=d; //# sourceMappingURL=index.cjs132.js.map