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