date-and-time 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +43 -2
- package/dist/index.js +1 -1
- package/dist/plugins/quarter.cjs +1 -0
- package/dist/plugins/quarter.d.ts +113 -0
- package/dist/plugins/quarter.js +1 -0
- package/dist/plugins/timestamp.cjs +1 -0
- package/dist/plugins/timestamp.d.ts +114 -0
- package/dist/plugins/timestamp.js +1 -0
- package/dist/plugins/week.cjs +1 -0
- package/dist/plugins/week.d.ts +117 -0
- package/dist/plugins/week.js +1 -0
- package/dist/plugins/zonename.cjs +1 -1
- package/dist/plugins/zonename.js +1 -1
- package/package.json +11 -12
package/README.md
CHANGED
|
@@ -17,10 +17,10 @@ The simplest, most intuitive date and time library.
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
19
19
|
```shell
|
|
20
|
-
npm
|
|
20
|
+
npm install date-and-time
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
### ES Modules (Recommended)
|
|
24
24
|
|
|
25
25
|
```typescript
|
|
26
26
|
import { format } from 'date-and-time';
|
|
@@ -29,7 +29,7 @@ format(new Date(), 'ddd, MMM DD YYYY');
|
|
|
29
29
|
// => Wed, Jul 09 2025
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
### CommonJS
|
|
33
33
|
|
|
34
34
|
```typescript
|
|
35
35
|
const { format } = require('date-and-time');
|
|
@@ -38,6 +38,28 @@ format(new Date(), 'ddd, MMM DD YYYY');
|
|
|
38
38
|
// => Wed, Jul 09 2025
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
## CDN Usage
|
|
42
|
+
|
|
43
|
+
### Via jsDelivr
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<script type="module">
|
|
47
|
+
import { format } from 'https://cdn.jsdelivr.net/npm/date-and-time/dist/index.js';
|
|
48
|
+
|
|
49
|
+
console.log(format(new Date(), 'YYYY/MM/DD'));
|
|
50
|
+
</script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Via unpkg
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<script type="module">
|
|
57
|
+
import { format } from 'https://unpkg.com/date-and-time/dist/index.js';
|
|
58
|
+
|
|
59
|
+
console.log(format(new Date(), 'YYYY/MM/DD'));
|
|
60
|
+
</script>
|
|
61
|
+
```
|
|
62
|
+
|
|
41
63
|
## Migration
|
|
42
64
|
|
|
43
65
|
Version `4.x` has been completely rewritten in TypeScript and some features from `3.x` are no longer compatible. The main changes are as follows:
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/** @preserve Copyright (c) KNOWLEDGECODE - MIT License */const e=/\\\[/g,t=/\\\]/g,n=/\uE000/g,r=/\uE001/g,s=/\[(?:[^[\]]|\[[^[\]]*])*]|([A-Za-z])\1*|\.{3}|./g,o=o=>{const a=o.replace(e,"").replace(t,"").match(s)??[];return[o,...a.map(e=>e.replace(n,"[").replace(r,"]"))]},a=new Map,i=e=>a.get(e)??(()=>{const t=new Intl.DateTimeFormat("en-US",{hour12:!1,weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,timeZone:e});return e&&a.set(e,t),t})(),c=e=>Date.UTC(e.year,e.month-(e.year<100?22801:1),e.day,e.hour,e.minute,e.second,e.fractionalSecond+6e4*e.timezoneOffset),u=(e,t)=>e.formatToParts(t).reduce((e,{type:t,value:n})=>{switch(t){case"weekday":e[t]="SunMonTueWedThuFriSat".indexOf(n)/3;break;case"hour":e[t]=+n%24;break;case"year":case"month":case"day":case"minute":case"second":case"fractionalSecond":e[t]=+n}return e},{weekday:4,year:1970,month:1,day:1,hour:0,minute:0,second:0,fractionalSecond:0,timezoneOffset:0}),l=e=>"string"==typeof e&&"UTC"===e.toUpperCase(),d=(e,t)=>{if(l(t))return{weekday:e.getUTCDay(),year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),fractionalSecond:e.getUTCMilliseconds(),timezoneOffset:0};const n=e.getTime(),r=u(i(t),n);return r.timezoneOffset=(n-c(r))/6e4,r};class h{constructor(e,t){this.parts=d(e,t),this.time=e.getTime()}getFullYear(){return this.parts.year}getMonth(){return this.parts.month-1}getDate(){return this.parts.day}getHours(){return this.parts.hour}getMinutes(){return this.parts.minute}getSeconds(){return this.parts.second}getMilliseconds(){return this.parts.fractionalSecond}getDay(){return this.parts.weekday}getTime(){return this.time}getTimezoneOffset(){return this.parts.timezoneOffset}}class m{}const g=(e,t)=>e.getFullYear()+("buddhist"===t?543:0);const M=new class extends m{YYYY(e,t){return`000${String(g(e,t.calendar))}`.slice(-4)}YY(e,t){return`0${String(g(e,t.calendar))}`.slice(-2)}Y(e,t){return String(g(e,t.calendar))}MMMM(e,t,n){return t.locale.getMonthList({style:"long",compiledObj:n})[e.getMonth()]??""}MMM(e,t,n){return t.locale.getMonthList({style:"short",compiledObj:n})[e.getMonth()]??""}MM(e){return`0${String(e.getMonth()+1)}`.slice(-2)}M(e){return String(e.getMonth()+1)}DD(e){return`0${String(e.getDate())}`.slice(-2)}D(e){return String(e.getDate())}HH(e,t){return`0${String(e.getHours()||("h24"===t.hour24?24:0))}`.slice(-2)}H(e,t){return String(e.getHours()||("h24"===t.hour24?24:0))}AA(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}A(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}aa(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}a(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}hh(e,t){return`0${String(e.getHours()%12||("h12"===t.hour12?12:0))}`.slice(-2)}h(e,t){return String(e.getHours()%12||("h12"===t.hour12?12:0))}mm(e){return`0${String(e.getMinutes())}`.slice(-2)}m(e){return String(e.getMinutes())}ss(e){return`0${String(e.getSeconds())}`.slice(-2)}s(e){return String(e.getSeconds())}SSS(e){return`00${String(e.getMilliseconds())}`.slice(-3)}SS(e){return`00${String(e.getMilliseconds())}`.slice(-3,-1)}S(e){return`00${String(e.getMilliseconds())}`.slice(-3,-2)}dddd(e,t,n){return t.locale.getDayOfWeekList({style:"long",compiledObj:n})[e.getDay()]??""}ddd(e,t,n){return t.locale.getDayOfWeekList({style:"short",compiledObj:n})[e.getDay()]??""}dd(e,t,n){return t.locale.getDayOfWeekList({style:"narrow",compiledObj:n})[e.getDay()]??""}Z(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}${`0${String(n%60)}`.slice(-2)}`}ZZ(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}:${`0${String(n%60)}`.slice(-2)}`}},f={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"],AA:["A.M.","P.M."],a:["am","pm"],aa:["a.m.","p.m."]};var p=new class{getLocale(){return"en"}getMonthList(e){return"long"===e.style?f.MMMM:f.MMM}getDayOfWeekList(e){return"long"===e.style?f.dddd:"short"===e.style?f.ddd:f.dd}getMeridiemList(e){return"long"===e.style?"lowercase"===e.case?f.aa:f.AA:"lowercase"===e.case?f.a:f.A}},y={encode:e=>e,decode:e=>e};const S=e=>!!e&&"object"==typeof e&&"zone_name"in e&&"gmt_offset"in e,D=(e,t)=>{const n=S(t)?t.zone_name:t;return new Date(e-((e,t)=>{const n=(()=>{try{return i(t)}catch{return}})(),r=new Set;if(n)for(let t=0;t<2;t++){const s=e-86400*t*1e3;let o=54822e3;do{const e=c(u(n,s-o))-s;if(0===e)return o;r.add(o),o+=e}while(!r.has(o));r.clear()}return NaN})(e,n))},T=/^\[(.*)\]$/;function b(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s=S(n?.timeZone)?n.timeZone.zone_name:n?.timeZone,a=s?new h(e,s):e,i={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??y,calendar:n?.calendar??"gregory",timeZone:n?.timeZone,locale:n?.locale??p},c=[...n?.plugins??[],M],u=i.numeral.encode;return r.reduce((e,t)=>e+((e,t)=>{for(const n of c)if(n[e])return u(n[e](a,i,t));return T.test(e)?e.replace(T,"$1"):e})(t,r),"")}class w{}const O=(e,t,n)=>{const r=e.exec(t)?.[0]??"";return{value:+r,length:r.length,token:n}},x=(e,t,n,r)=>{const[s,o]=n.ignoreCase?(()=>{const r=n.locale.getLocale();return[e.map(e=>e.toLocaleLowerCase(r)),t.toLocaleLowerCase(r)]})():[e,t];return s.reduce((e,t,n)=>t.length>e.length&&!o.indexOf(t)?{value:n,length:t.length,token:r}:e,{value:-1,length:0,token:r})},C=new Set(["Y","M","D","H","A","h","m","s","S","Z"]),v=e=>C.has(e);const Y=new class extends w{YYYY(e){return O(/^\d{4}/,e,"Y")}Y(e){return O(/^\d{1,4}/,e,"Y")}MMMM(e,t,n){const r=t.locale.getMonthList({style:"long",compiledObj:n}),s=x(r,e,t,"M");return s.value++,s}MMM(e,t,n){const r=t.locale.getMonthList({style:"short",compiledObj:n}),s=x(r,e,t,"M");return s.value++,s}MM(e){return O(/^\d\d/,e,"M")}M(e){return O(/^\d\d?/,e,"M")}DD(e){return O(/^\d\d/,e,"D")}D(e){return O(/^\d\d?/,e,"D")}HH(e){return O(/^\d\d/,e,"H")}H(e){return O(/^\d\d?/,e,"H")}AA(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"});return x(r,e,t,"A")}A(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"});return x(r,e,t,"A")}aa(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"});return x(r,e,t,"A")}a(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"});return x(r,e,t,"A")}hh(e){return O(/^\d\d/,e,"h")}h(e){return O(/^\d\d?/,e,"h")}mm(e){return O(/^\d\d/,e,"m")}m(e){return O(/^\d\d?/,e,"m")}ss(e){return O(/^\d\d/,e,"s")}s(e){return O(/^\d\d?/,e,"s")}SSS(e){return O(/^\d{1,3}/,e,"S")}SS(e){const t=O(/^\d\d?/,e,"S");return t.value*=10,t}S(e){const t=O(/^\d/,e,"S");return t.value*=100,t}Z(e){const t=O(/^[+-][01]\d[0-5]\d/,e,"Z");return t.value=-60*(t.value/100|0)-t.value%100,t}ZZ(e){const t=/^([+-][01]\d):([0-5]\d)/.exec(e)??["","",""],n=+(t[1]+t[2]);return{value:-60*(n/100|0)-n%100,length:t[0].length,token:"Z"}}},$=/^\[(.*)\]$/;function H(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??y,calendar:n?.calendar??"gregory",ignoreCase:n?.ignoreCase??!1,timeZone:(S(n?.timeZone)||"string"==typeof n?.timeZone)&&n.timeZone||void 0,locale:n?.locale??p},a={_index:0,_length:0,_match:0},i=[...n?.plugins??[],Y],c=(e,t)=>{for(const n of i)if(n[e])return n[e](t,s,r)};e=s.numeral.decode(e);for(const t of r){const n=e.substring(a._index),r=c(t,n);if(r){if(!r.length)break;r.token&&v(r.token)&&(a[r.token]=r.value+0),a._index+=r.length,a._match++}else if(t===n[0]||" "===t)a._index++;else{if(!$.test(t)||n.indexOf(t.replace($,"$1"))){if("..."===t){a._index=e.length;break}break}a._index+=t.length-2}}return a._length=e.length,a}function U(e,t){const n=void 0===e.Y?1970:e.Y-("buddhist"===t?.calendar?543:0),[r,s]="h11"===t?.hour12?[0,11]:[1,12],[o,a]="h24"===t?.hour24?[1,24]:[0,23],i=(e,t,n)=>void 0===e||e>=t&&e<=n;return e._index>0&&e._length>0&&e._index===e._length&&e._match>0&&i(n,1,9999)&&i(e.M,1,12)&&i(e.D,1,(c=n,u=e.M??1,new Date(Date.UTC(c,u-(c<100?22800:0),0)).getUTCDate()))&&i(e.H,o,a)&&i(e.A,0,1)&&i(e.h,r,s)&&i(e.m,0,59)&&i(e.s,0,59)&&i(e.S,0,999)&&i(e.Z,-913,956);var c,u}function A(e,t,n){const r=H(e,t,n);return U(r,n)?(r.Y=r.Y?r.Y-("buddhist"===n?.calendar?543:0):1970,r.M=(r.M??1)-(r.Y<100?22801:1),r.D??=1,r.H=(r.H??0)%24||12*(r.A??0)+(r.h??0)%12,r.m??=0,r.s??=0,r.S??=0,l(n?.timeZone)||"Z"in r?new Date(Date.UTC(r.Y,r.M,r.D,r.H,r.m+(r.Z??0),r.s,r.S)):n?.timeZone?D(Date.UTC(r.Y,r.M,r.D,r.H,r.m,r.s,r.S),n.timeZone):new Date(r.Y,r.M,r.D,r.H,r.m,r.s,r.S)):new Date(NaN)}function Z(e,t,n){const r=S(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCMonth(r.getUTCMonth()+t),r.getUTCDate()<e.getUTCDate()?(r.setUTCDate(0),r):r):(r.setMonth(r.getMonth()+t),r.getDate()<e.getDate()?(r.setDate(0),r):r)}const s=d(e,r);s.month+=t,s.timezoneOffset=0;const o=new Date(c(s));return o.getUTCDate()<s.day&&o.setUTCDate(0),D(c({...s,year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate()}),r)}const L=/^\[(.*)\]$/,k=(e,t)=>(e.F=Math.trunc(1e6*t),e),_=(e,t)=>(e.f=Math.trunc(1e3*t),k(e,1e3*Math.abs(t)%1/1e3)),j=(e,t)=>(e.S=Math.trunc(t),_(e,Math.abs(t)%1)),z=(e,t)=>(e.s=Math.trunc(t/1e3),j(e,Math.abs(t)%1e3)),F=(e,t)=>(e.m=Math.trunc(t/6e4),z(e,Math.abs(t)%6e4)),P=(e,t)=>(e.H=Math.trunc(t/36e5),F(e,Math.abs(t)%36e5)),W=(e,t,n=y)=>{const r=o(t).slice(1);return r.reduce((t,r)=>t+(t=>{if(t[0]in e){const r=e[t[0]]??0;return n.encode(`${(e=>e<0||0===e&&1/e==-1/0?"-":"")(r)}${String(Math.abs(r)).padStart(t.length,"0")}`)}return L.test(t)?t.replace(L,"$1"):t})(r),"")};class N{constructor(e){this.time=e}toNanoseconds(){return{value:1e6*this.time,format:(e,t)=>W(k({},this.time),e,t),toParts:()=>({nanoseconds:Math.trunc(1e6*this.time)+0})}}toMicroseconds(){return{value:1e3*this.time,format:(e,t)=>W(_({},this.time),e,t),toParts:()=>({microseconds:Math.trunc(1e3*this.time)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMilliseconds(){return{value:this.time,format:(e,t)=>W(j({},this.time),e,t),toParts:()=>({milliseconds:Math.trunc(this.time)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toSeconds(){return{value:this.time/1e3,format:(e,t)=>W(z({},this.time),e,t),toParts:()=>({seconds:Math.trunc(this.time/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMinutes(){return{value:this.time/6e4,format:(e,t)=>W(F({},this.time),e,t),toParts:()=>({minutes:Math.trunc(this.time/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toHours(){return{value:this.time/36e5,format:(e,t)=>W(P({},this.time),e,t),toParts:()=>({hours:Math.trunc(this.time/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toDays(){return{value:this.time/864e5,format:(e,t)=>{return W((n={},r=this.time,n.D=Math.trunc(r/864e5),P(n,Math.abs(r)%864e5)),e,t);var n,r},toParts:()=>({days:Math.trunc(this.time/864e5)+0,hours:Math.trunc(this.time%864e5/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}}exports.Duration=N,exports.addDays=function(e,t,n){const r=S(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCDate(r.getUTCDate()+t),r):(r.setDate(r.getDate()+t),r)}const s=d(e,r);return s.day+=t,s.timezoneOffset=0,D(c(s),r)},exports.addHours=function(e,t){return new Date(e.getTime()+36e5*t)},exports.addMilliseconds=function(e,t){return new Date(e.getTime()+t)},exports.addMinutes=function(e,t){return new Date(e.getTime()+6e4*t)},exports.addMonths=Z,exports.addSeconds=function(e,t){return new Date(e.getTime()+1e3*t)},exports.addYears=function(e,t,n){return Z(e,12*t,n)},exports.compile=o,exports.format=b,exports.isLeapYear=e=>!((e%4||!(e%100))&&e%400),exports.isSameDay=(e,t)=>e.toDateString()===t.toDateString(),exports.isValid=function(e,t,n){return U(H(e,t,n),n)},exports.parse=A,exports.preparse=H,exports.subtract=(e,t)=>new N(t.getTime()-e.getTime()),exports.transform=function(e,t,n,r,s){return b(A(e,t,r),n,s)};
|
|
2
|
+
/** @preserve Copyright (c) KNOWLEDGECODE - MIT License */const e=/\\\[/g,t=/\\\]/g,n=/\uE000/g,r=/\uE001/g,s=/\[(?:[^[\]]|\[[^[\]]*])*]|([A-Za-z])\1*|\.{3}|./g,o=o=>{const a=o.replace(e,"").replace(t,"").match(s)??[];return[o,...a.map(e=>e.replace(n,"[").replace(r,"]"))]},a=new Map,i=e=>a.get(e)??(()=>{const t=new Intl.DateTimeFormat("en-US",{hour12:!1,weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,timeZone:e});return e&&a.set(e,t),t})(),c=e=>Date.UTC(e.year,e.month-(e.year<100?22801:1),e.day,e.hour,e.minute,e.second,e.fractionalSecond+6e4*e.timezoneOffset),u=(e,t)=>e.formatToParts(t).reduce((e,{type:t,value:n})=>{switch(t){case"weekday":e[t]="SunMonTueWedThuFriSat".indexOf(n)/3;break;case"hour":e[t]=+n%24;break;case"year":case"month":case"day":case"minute":case"second":case"fractionalSecond":e[t]=+n}return e},{weekday:4,year:1970,month:1,day:1,hour:0,minute:0,second:0,fractionalSecond:0,timezoneOffset:0}),l=e=>"string"==typeof e&&"UTC"===e.toUpperCase(),d=(e,t)=>{if(l(t))return{weekday:e.getUTCDay(),year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),fractionalSecond:e.getUTCMilliseconds(),timezoneOffset:0};const n=e.getTime(),r=u(i(t),n);return r.timezoneOffset=(n-c(r))/6e4,r};class h{constructor(e,t){this.parts=d(e,t),this.time=e.getTime()}getFullYear(){return this.parts.year}getMonth(){return this.parts.month-1}getDate(){return this.parts.day}getHours(){return this.parts.hour}getMinutes(){return this.parts.minute}getSeconds(){return this.parts.second}getMilliseconds(){return this.parts.fractionalSecond}getDay(){return this.parts.weekday}getTime(){return this.time}getTimezoneOffset(){return this.parts.timezoneOffset}}class m{}const g=(e,t)=>e.getFullYear()+("buddhist"===t?543:0);const M=new class extends m{YYYY(e,t){return`000${String(g(e,t.calendar))}`.slice(-4)}YY(e,t){return`0${String(g(e,t.calendar))}`.slice(-2)}Y(e,t){return String(g(e,t.calendar))}MMMM(e,t,n){return t.locale.getMonthList({style:"long",compiledObj:n})[e.getMonth()]??""}MMM(e,t,n){return t.locale.getMonthList({style:"short",compiledObj:n})[e.getMonth()]??""}MM(e){return`0${String(e.getMonth()+1)}`.slice(-2)}M(e){return String(e.getMonth()+1)}DD(e){return`0${String(e.getDate())}`.slice(-2)}D(e){return String(e.getDate())}HH(e,t){return`0${String(e.getHours()||("h24"===t.hour24?24:0))}`.slice(-2)}H(e,t){return String(e.getHours()||("h24"===t.hour24?24:0))}AA(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}A(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}aa(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}a(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}hh(e,t){return`0${String(e.getHours()%12||("h12"===t.hour12?12:0))}`.slice(-2)}h(e,t){return String(e.getHours()%12||("h12"===t.hour12?12:0))}mm(e){return`0${String(e.getMinutes())}`.slice(-2)}m(e){return String(e.getMinutes())}ss(e){return`0${String(e.getSeconds())}`.slice(-2)}s(e){return String(e.getSeconds())}SSS(e){return`00${String(e.getMilliseconds())}`.slice(-3)}SS(e){return`00${String(e.getMilliseconds())}`.slice(-3,-1)}S(e){return`00${String(e.getMilliseconds())}`.slice(-3,-2)}dddd(e,t,n){return t.locale.getDayOfWeekList({style:"long",compiledObj:n})[e.getDay()]??""}ddd(e,t,n){return t.locale.getDayOfWeekList({style:"short",compiledObj:n})[e.getDay()]??""}dd(e,t,n){return t.locale.getDayOfWeekList({style:"narrow",compiledObj:n})[e.getDay()]??""}Z(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}${`0${String(n%60)}`.slice(-2)}`}ZZ(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}:${`0${String(n%60)}`.slice(-2)}`}},f={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"],AA:["A.M.","P.M."],a:["am","pm"],aa:["a.m.","p.m."]};var p=new class{getLocale(){return"en"}getMonthList(e){return"long"===e.style?f.MMMM:f.MMM}getDayOfWeekList(e){return"long"===e.style?f.dddd:"short"===e.style?f.ddd:f.dd}getMeridiemList(e){return"long"===e.style?"lowercase"===e.case?f.aa:f.AA:"lowercase"===e.case?f.a:f.A}},y={encode:e=>e,decode:e=>e};const S=e=>!!e&&"object"==typeof e&&"zone_name"in e&&"gmt_offset"in e,D=(e,t)=>{const n=S(t)?t.zone_name:t;return new Date(e-((e,t)=>{const n=(()=>{try{return i(t)}catch{return}})(),r=new Set;if(n)for(let t=0;t<2;t++){const s=e-86400*t*1e3;let o=54822e3;do{const e=c(u(n,s-o))-s;if(0===e)return o;r.add(o),o+=e}while(!r.has(o));r.clear()}return NaN})(e,n))},T=/^\[(.*)\]$/;function b(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s=S(n?.timeZone)?n.timeZone.zone_name:n?.timeZone,a=s?new h(e,s):e,i={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??y,calendar:n?.calendar??"gregory",timeZone:n?.timeZone,locale:n?.locale??p},c=[...n?.plugins??[],M],u=i.numeral.encode;return r.reduce((e,t)=>e+((e,t)=>{for(const n of c)if(n[e])return u(n[e](a,i,t));return T.test(e)?e.replace(T,"$1"):e})(t,r),"")}class w{}const C=(e,t,n)=>{const r=e.exec(t)?.[0]??"";return{value:+r,length:r.length,token:n}},O=(e,t,n,r)=>{const[s,o]=n.ignoreCase?(()=>{const r=n.locale.getLocale();return[e.map(e=>e.toLocaleLowerCase(r)),t.toLocaleLowerCase(r)]})():[e,t];return s.reduce((e,t,n)=>t.length>e.length&&!o.indexOf(t)?{value:n,length:t.length,token:r}:e,{value:-1,length:0,token:r})},Y=new Set(["Y","M","D","H","A","h","m","s","S","Z"]),x=e=>Y.has(e);const U=new class extends w{YYYY(e){return C(/^\d{4}/,e,"Y")}Y(e){return C(/^\d{1,4}/,e,"Y")}MMMM(e,t,n){const r=t.locale.getMonthList({style:"long",compiledObj:n}),s=O(r,e,t,"M");return s.value++,s}MMM(e,t,n){const r=t.locale.getMonthList({style:"short",compiledObj:n}),s=O(r,e,t,"M");return s.value++,s}MM(e){return C(/^\d\d/,e,"M")}M(e){return C(/^\d\d?/,e,"M")}DD(e){return C(/^\d\d/,e,"D")}D(e){return C(/^\d\d?/,e,"D")}HH(e){return C(/^\d\d/,e,"H")}H(e){return C(/^\d\d?/,e,"H")}AA(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"});return O(r,e,t,"A")}A(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"});return O(r,e,t,"A")}aa(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"});return O(r,e,t,"A")}a(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"});return O(r,e,t,"A")}hh(e){return C(/^\d\d/,e,"h")}h(e){return C(/^\d\d?/,e,"h")}mm(e){return C(/^\d\d/,e,"m")}m(e){return C(/^\d\d?/,e,"m")}ss(e){return C(/^\d\d/,e,"s")}s(e){return C(/^\d\d?/,e,"s")}SSS(e){return C(/^\d{1,3}/,e,"S")}SS(e){const t=C(/^\d\d?/,e,"S");return t.value*=10,t}S(e){const t=C(/^\d/,e,"S");return t.value*=100,t}Z(e){const t=C(/^[+-][01]\d[0-5]\d/,e,"Z");return t.value=-60*(t.value/100|0)-t.value%100,t}ZZ(e){const t=/^([+-][01]\d):([0-5]\d)/.exec(e)??["","",""],n=+(t[1]+t[2]);return{value:-60*(n/100|0)-n%100,length:t[0].length,token:"Z"}}},v=/^\[(.*)\]$/;function $(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??y,calendar:n?.calendar??"gregory",ignoreCase:n?.ignoreCase??!1,timeZone:(S(n?.timeZone)||"string"==typeof n?.timeZone)&&n.timeZone||void 0,locale:n?.locale??p},a={_index:0,_length:0,_match:0},i=[...n?.plugins??[],U],c=(e,t)=>{for(const n of i)if(n[e])return n[e](t,s,r)};e=s.numeral.decode(e);for(const t of r){const n=e.substring(a._index),r=c(t,n);if(r){if(!r.length)break;r.token&&x(r.token)&&(a[r.token]=r.value+0),a._index+=r.length,a._match++}else if(t===n[0]||" "===t)a._index++;else{if(!v.test(t)||n.indexOf(t.replace(v,"$1"))){if("..."===t){a._index=e.length;break}break}a._index+=t.length-2}}return a._length=e.length,a}const H=(e,t,n)=>Date.UTC(e,t-(e<100?22800:0),n);function A(...e){const[t,n]=1===e.length?[e[0].getFullYear(),e[0].getMonth()+1]:e;return new Date(H(t,n,0)).getUTCDate()}const Z=e=>{const t=new Date(e);return t.setUTCDate(t.getUTCDate()+(4-(t.getUTCDay()||7))),t};function L(e,t){const n=void 0===e.Y?1970:e.Y-("buddhist"===t?.calendar?543:0),[r,s]="h11"===t?.hour12?[0,11]:[1,12],[o,a]="h24"===t?.hour24?[1,24]:[0,23],i=(e,t,n)=>void 0===e||e>=t&&e<=n;return e._index>0&&e._length>0&&e._index===e._length&&e._match>0&&i(n,1,9999)&&i(e.M,1,12)&&i(e.D,1,A(n,e.M??1))&&i(e.H,o,a)&&i(e.A,0,1)&&i(e.h,r,s)&&i(e.m,0,59)&&i(e.s,0,59)&&i(e.S,0,999)&&i(e.Z,-913,956)}function k(e,t,n){const r=$(e,t,n);return L(r,n)?(r.Y=r.Y?r.Y-("buddhist"===n?.calendar?543:0):1970,r.M=(r.M??1)-(r.Y<100?22801:1),r.D??=1,r.H=(r.H??0)%24||12*(r.A??0)+(r.h??0)%12,r.m??=0,r.s??=0,r.S??=0,l(n?.timeZone)||"Z"in r?new Date(Date.UTC(r.Y,r.M,r.D,r.H,r.m+(r.Z??0),r.s,r.S)):n?.timeZone?D(Date.UTC(r.Y,r.M,r.D,r.H,r.m,r.s,r.S),n.timeZone):new Date(r.Y,r.M,r.D,r.H,r.m,r.s,r.S)):new Date(NaN)}function _(e,t,n){const r=S(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCMonth(r.getUTCMonth()+t),r.getUTCDate()<e.getUTCDate()?(r.setUTCDate(0),r):r):(r.setMonth(r.getMonth()+t),r.getDate()<e.getDate()?(r.setDate(0),r):r)}const s=d(e,r);s.month+=t,s.timezoneOffset=0;const o=new Date(c(s));return o.getUTCDate()<s.day&&o.setUTCDate(0),D(c({...s,year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate()}),r)}const F=/^\[(.*)\]$/,j=(e,t)=>(e.F=Math.trunc(1e6*t),e),z=(e,t)=>(e.f=Math.trunc(1e3*t),j(e,1e3*Math.abs(t)%1/1e3)),P=(e,t)=>(e.S=Math.trunc(t),z(e,Math.abs(t)%1)),W=(e,t)=>(e.s=Math.trunc(t/1e3),P(e,Math.abs(t)%1e3)),N=(e,t)=>(e.m=Math.trunc(t/6e4),W(e,Math.abs(t)%6e4)),J=(e,t)=>(e.H=Math.trunc(t/36e5),N(e,Math.abs(t)%36e5)),I=(e,t,n=y)=>{const r=o(t).slice(1);return r.reduce((t,r)=>t+(t=>{if(t[0]in e){const r=e[t[0]]??0;return n.encode(`${(e=>e<0||0===e&&1/e==-1/0?"-":"")(r)}${String(Math.abs(r)).padStart(t.length,"0")}`)}return F.test(t)?t.replace(F,"$1"):t})(r),"")};class E{constructor(e){this.time=e}toNanoseconds(){return{value:1e6*this.time,format:(e,t)=>I(j({},this.time),e,t),toParts:()=>({nanoseconds:Math.trunc(1e6*this.time)+0})}}toMicroseconds(){return{value:1e3*this.time,format:(e,t)=>I(z({},this.time),e,t),toParts:()=>({microseconds:Math.trunc(1e3*this.time)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMilliseconds(){return{value:this.time,format:(e,t)=>I(P({},this.time),e,t),toParts:()=>({milliseconds:Math.trunc(this.time)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toSeconds(){return{value:this.time/1e3,format:(e,t)=>I(W({},this.time),e,t),toParts:()=>({seconds:Math.trunc(this.time/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMinutes(){return{value:this.time/6e4,format:(e,t)=>I(N({},this.time),e,t),toParts:()=>({minutes:Math.trunc(this.time/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toHours(){return{value:this.time/36e5,format:(e,t)=>I(J({},this.time),e,t),toParts:()=>({hours:Math.trunc(this.time/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toDays(){return{value:this.time/864e5,format:(e,t)=>{return I((n={},r=this.time,n.D=Math.trunc(r/864e5),J(n,Math.abs(r)%864e5)),e,t);var n,r},toParts:()=>({days:Math.trunc(this.time/864e5)+0,hours:Math.trunc(this.time%864e5/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}}exports.Duration=E,exports.addDays=function(e,t,n){const r=S(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCDate(r.getUTCDate()+t),r):(r.setDate(r.getDate()+t),r)}const s=d(e,r);return s.day+=t,s.timezoneOffset=0,D(c(s),r)},exports.addHours=function(e,t){return new Date(e.getTime()+36e5*t)},exports.addMilliseconds=function(e,t){return new Date(e.getTime()+t)},exports.addMinutes=function(e,t){return new Date(e.getTime()+6e4*t)},exports.addMonths=_,exports.addSeconds=function(e,t){return new Date(e.getTime()+1e3*t)},exports.addYears=function(e,t,n){return _(e,12*t,n)},exports.compile=o,exports.format=b,exports.getDaysInMonth=A,exports.getISOWeek=function(...e){const[t,n,r]=1===e.length?[e[0].getFullYear(),e[0].getMonth()+1,e[0].getDate()]:e,s=Z(H(t,n-1,r));return Math.round((s.getTime()-Z(H(s.getUTCFullYear(),0,4)).getTime())/864e5/7)+1},exports.getISOWeekYear=function(...e){const[t,n,r]=1===e.length?[e[0].getFullYear(),e[0].getMonth()+1,e[0].getDate()]:e;return Z(H(t,n-1,r)).getUTCFullYear()},exports.isLeapYear=e=>!((e%4||!(e%100))&&e%400),exports.isSameDay=(e,t)=>e.toDateString()===t.toDateString(),exports.isValid=function(e,t,n){return L($(e,t,n),n)},exports.parse=k,exports.preparse=$,exports.subtract=(e,t)=>new E(t.getTime()-e.getTime()),exports.transform=function(e,t,n,r,s){return b(k(e,t,r),n,s)};
|
package/dist/index.d.ts
CHANGED
|
@@ -425,7 +425,7 @@ declare const subtract: (from: Date, to: Date) => Duration;
|
|
|
425
425
|
|
|
426
426
|
/**
|
|
427
427
|
* Determines if the specified year is a leap year.
|
|
428
|
-
* @param year - The year to check
|
|
428
|
+
* @param year - The gregorian year to check for leap year status (1-9999)
|
|
429
429
|
* @returns True if the year is a leap year, false otherwise
|
|
430
430
|
*/
|
|
431
431
|
declare const isLeapYear: (year: number) => boolean;
|
|
@@ -436,5 +436,46 @@ declare const isLeapYear: (year: number) => boolean;
|
|
|
436
436
|
* @returns True if both dates are on the same day, false otherwise
|
|
437
437
|
*/
|
|
438
438
|
declare const isSameDay: (date1: Date, date2: Date) => boolean;
|
|
439
|
+
/**
|
|
440
|
+
* Returns the number of days in a given month of a specific year.
|
|
441
|
+
* @param date - The date to get the number of days for
|
|
442
|
+
* @returns The number of days in the month of the provided date
|
|
443
|
+
*/
|
|
444
|
+
declare function getDaysInMonth(date: Date): number;
|
|
445
|
+
/**
|
|
446
|
+
* Returns the number of days in a given month of a specific year.
|
|
447
|
+
* @param year - The gregorian year (1-9999) to get the number of days for
|
|
448
|
+
* @param month - The month (1-12) to get the number of days for
|
|
449
|
+
* @returns The number of days in the month of the provided date
|
|
450
|
+
*/
|
|
451
|
+
declare function getDaysInMonth(year: number, month: number): number;
|
|
452
|
+
/**
|
|
453
|
+
* Calculates the ISO week year for a given date.
|
|
454
|
+
* @param date - The date to calculate the ISO week year for
|
|
455
|
+
* @returns The ISO week year corresponding to the provided date
|
|
456
|
+
*/
|
|
457
|
+
declare function getISOWeekYear(date: Date): number;
|
|
458
|
+
/**
|
|
459
|
+
* Calculates the ISO week year for a given year, month, and day.
|
|
460
|
+
* @param year - The gregorian year (1-9999) to calculate the ISO week year for
|
|
461
|
+
* @param month - The month (1-12) to calculate the ISO week year for
|
|
462
|
+
* @param day - The day (1-31) to calculate the ISO week year for
|
|
463
|
+
* @returns The ISO week year corresponding to the provided date
|
|
464
|
+
*/
|
|
465
|
+
declare function getISOWeekYear(year: number, month: number, day: number): number;
|
|
466
|
+
/**
|
|
467
|
+
* Calculates the ISO week number for a given date.
|
|
468
|
+
* @param date - The date to calculate the ISO week number for
|
|
469
|
+
* @returns The ISO week number corresponding to the provided date
|
|
470
|
+
*/
|
|
471
|
+
declare function getISOWeek(date: Date): number;
|
|
472
|
+
/**
|
|
473
|
+
* Calculates the ISO week number for a given year, month, and day.
|
|
474
|
+
* @param year - The gregorian year (1-9999) to calculate the ISO week number for
|
|
475
|
+
* @param month - The month (1-12) to calculate the ISO week number for
|
|
476
|
+
* @param day - The day (1-31) to calculate the ISO week number for
|
|
477
|
+
* @returns The ISO week number corresponding to the provided date
|
|
478
|
+
*/
|
|
479
|
+
declare function getISOWeek(year: number, month: number, day: number): number;
|
|
439
480
|
|
|
440
|
-
export { Duration, addDays, addHours, addMilliseconds, addMinutes, addMonths, addSeconds, addYears, compile, format, isLeapYear, isSameDay, isValid, parse, preparse, subtract, transform };
|
|
481
|
+
export { Duration, addDays, addHours, addMilliseconds, addMinutes, addMonths, addSeconds, addYears, compile, format, getDaysInMonth, getISOWeek, getISOWeekYear, isLeapYear, isSameDay, isValid, parse, preparse, subtract, transform };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** @preserve Copyright (c) KNOWLEDGECODE - MIT License */
|
|
2
|
-
const e=/\\\[/g,t=/\\\]/g,n=/\uE000/g,r=/\uE001/g,s=/\[(?:[^[\]]|\[[^[\]]*])*]|([A-Za-z])\1*|\.{3}|./g,o=o=>{const a=o.replace(e,"").replace(t,"").match(s)??[];return[o,...a.map(e=>e.replace(n,"[").replace(r,"]"))]},a=new Map,i=e=>a.get(e)??(()=>{const t=new Intl.DateTimeFormat("en-US",{hour12:!1,weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,timeZone:e});return e&&a.set(e,t),t})(),c=e=>Date.UTC(e.year,e.month-(e.year<100?22801:1),e.day,e.hour,e.minute,e.second,e.fractionalSecond+6e4*e.timezoneOffset),u=(e,t)=>e.formatToParts(t).reduce((e,{type:t,value:n})=>{switch(t){case"weekday":e[t]="SunMonTueWedThuFriSat".indexOf(n)/3;break;case"hour":e[t]=+n%24;break;case"year":case"month":case"day":case"minute":case"second":case"fractionalSecond":e[t]=+n}return e},{weekday:4,year:1970,month:1,day:1,hour:0,minute:0,second:0,fractionalSecond:0,timezoneOffset:0}),l=e=>"string"==typeof e&&"UTC"===e.toUpperCase(),h=(e,t)=>{if(l(t))return{weekday:e.getUTCDay(),year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),fractionalSecond:e.getUTCMilliseconds(),timezoneOffset:0};const n=e.getTime(),r=u(i(t),n);return r.timezoneOffset=(n-c(r))/6e4,r};class d{constructor(e,t){this.parts=h(e,t),this.time=e.getTime()}getFullYear(){return this.parts.year}getMonth(){return this.parts.month-1}getDate(){return this.parts.day}getHours(){return this.parts.hour}getMinutes(){return this.parts.minute}getSeconds(){return this.parts.second}getMilliseconds(){return this.parts.fractionalSecond}getDay(){return this.parts.weekday}getTime(){return this.time}getTimezoneOffset(){return this.parts.timezoneOffset}}class m{}const g=(e,t)=>e.getFullYear()+("buddhist"===t?543:0);const M=new class extends m{YYYY(e,t){return`000${String(g(e,t.calendar))}`.slice(-4)}YY(e,t){return`0${String(g(e,t.calendar))}`.slice(-2)}Y(e,t){return String(g(e,t.calendar))}MMMM(e,t,n){return t.locale.getMonthList({style:"long",compiledObj:n})[e.getMonth()]??""}MMM(e,t,n){return t.locale.getMonthList({style:"short",compiledObj:n})[e.getMonth()]??""}MM(e){return`0${String(e.getMonth()+1)}`.slice(-2)}M(e){return String(e.getMonth()+1)}DD(e){return`0${String(e.getDate())}`.slice(-2)}D(e){return String(e.getDate())}HH(e,t){return`0${String(e.getHours()||("h24"===t.hour24?24:0))}`.slice(-2)}H(e,t){return String(e.getHours()||("h24"===t.hour24?24:0))}AA(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}A(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}aa(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}a(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}hh(e,t){return`0${String(e.getHours()%12||("h12"===t.hour12?12:0))}`.slice(-2)}h(e,t){return String(e.getHours()%12||("h12"===t.hour12?12:0))}mm(e){return`0${String(e.getMinutes())}`.slice(-2)}m(e){return String(e.getMinutes())}ss(e){return`0${String(e.getSeconds())}`.slice(-2)}s(e){return String(e.getSeconds())}SSS(e){return`00${String(e.getMilliseconds())}`.slice(-3)}SS(e){return`00${String(e.getMilliseconds())}`.slice(-3,-1)}S(e){return`00${String(e.getMilliseconds())}`.slice(-3,-2)}dddd(e,t,n){return t.locale.getDayOfWeekList({style:"long",compiledObj:n})[e.getDay()]??""}ddd(e,t,n){return t.locale.getDayOfWeekList({style:"short",compiledObj:n})[e.getDay()]??""}dd(e,t,n){return t.locale.getDayOfWeekList({style:"narrow",compiledObj:n})[e.getDay()]??""}Z(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}${`0${String(n%60)}`.slice(-2)}`}ZZ(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}:${`0${String(n%60)}`.slice(-2)}`}},f={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"],AA:["A.M.","P.M."],a:["am","pm"],aa:["a.m.","p.m."]};var y=new class{getLocale(){return"en"}getMonthList(e){return"long"===e.style?f.MMMM:f.MMM}getDayOfWeekList(e){return"long"===e.style?f.dddd:"short"===e.style?f.ddd:f.dd}getMeridiemList(e){return"long"===e.style?"lowercase"===e.case?f.aa:f.AA:"lowercase"===e.case?f.a:f.A}},S={encode:e=>e,decode:e=>e};const D=e=>!!e&&"object"==typeof e&&"zone_name"in e&&"gmt_offset"in e,p=(e,t)=>{const n=D(t)?t.zone_name:t;return new Date(e-((e,t)=>{const n=(()=>{try{return i(t)}catch{return}})(),r=new Set;if(n)for(let t=0;t<2;t++){const s=e-86400*t*1e3;let o=54822e3;do{const e=c(u(n,s-o))-s;if(0===e)return o;r.add(o),o+=e}while(!r.has(o));r.clear()}return NaN})(e,n))},T=/^\[(.*)\]$/;function b(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s=D(n?.timeZone)?n.timeZone.zone_name:n?.timeZone,a=s?new d(e,s):e,i={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??S,calendar:n?.calendar??"gregory",timeZone:n?.timeZone,locale:n?.locale??y},c=[...n?.plugins??[],M],u=i.numeral.encode;return r.reduce((e,t)=>e+((e,t)=>{for(const n of c)if(n[e])return u(n[e](a,i,t));return T.test(e)?e.replace(T,"$1"):e})(t,r),"")}class w{}const O=(e,t,n)=>{const r=e.exec(t)?.[0]??"";return{value:+r,length:r.length,token:n}},C=(e,t,n,r)=>{const[s,o]=n.ignoreCase?(()=>{const r=n.locale.getLocale();return[e.map(e=>e.toLocaleLowerCase(r)),t.toLocaleLowerCase(r)]})():[e,t];return s.reduce((e,t,n)=>t.length>e.length&&!o.indexOf(t)?{value:n,length:t.length,token:r}:e,{value:-1,length:0,token:r})},v=new Set(["Y","M","D","H","A","h","m","s","S","Z"]),$=e=>v.has(e);const U=new class extends w{YYYY(e){return O(/^\d{4}/,e,"Y")}Y(e){return O(/^\d{1,4}/,e,"Y")}MMMM(e,t,n){const r=t.locale.getMonthList({style:"long",compiledObj:n}),s=C(r,e,t,"M");return s.value++,s}MMM(e,t,n){const r=t.locale.getMonthList({style:"short",compiledObj:n}),s=C(r,e,t,"M");return s.value++,s}MM(e){return O(/^\d\d/,e,"M")}M(e){return O(/^\d\d?/,e,"M")}DD(e){return O(/^\d\d/,e,"D")}D(e){return O(/^\d\d?/,e,"D")}HH(e){return O(/^\d\d/,e,"H")}H(e){return O(/^\d\d?/,e,"H")}AA(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"});return C(r,e,t,"A")}A(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"});return C(r,e,t,"A")}aa(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"});return C(r,e,t,"A")}a(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"});return C(r,e,t,"A")}hh(e){return O(/^\d\d/,e,"h")}h(e){return O(/^\d\d?/,e,"h")}mm(e){return O(/^\d\d/,e,"m")}m(e){return O(/^\d\d?/,e,"m")}ss(e){return O(/^\d\d/,e,"s")}s(e){return O(/^\d\d?/,e,"s")}SSS(e){return O(/^\d{1,3}/,e,"S")}SS(e){const t=O(/^\d\d?/,e,"S");return t.value*=10,t}S(e){const t=O(/^\d/,e,"S");return t.value*=100,t}Z(e){const t=O(/^[+-][01]\d[0-5]\d/,e,"Z");return t.value=-60*(t.value/100|0)-t.value%100,t}ZZ(e){const t=/^([+-][01]\d):([0-5]\d)/.exec(e)??["","",""],n=+(t[1]+t[2]);return{value:-60*(n/100|0)-n%100,length:t[0].length,token:"Z"}}},Y=/^\[(.*)\]$/;function H(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??S,calendar:n?.calendar??"gregory",ignoreCase:n?.ignoreCase??!1,timeZone:(D(n?.timeZone)||"string"==typeof n?.timeZone)&&n.timeZone||void 0,locale:n?.locale??y},a={_index:0,_length:0,_match:0},i=[...n?.plugins??[],U],c=(e,t)=>{for(const n of i)if(n[e])return n[e](t,s,r)};e=s.numeral.decode(e);for(const t of r){const n=e.substring(a._index),r=c(t,n);if(r){if(!r.length)break;r.token&&$(r.token)&&(a[r.token]=r.value+0),a._index+=r.length,a._match++}else if(t===n[0]||" "===t)a._index++;else{if(!Y.test(t)||n.indexOf(t.replace(Y,"$1"))){if("..."===t){a._index=e.length;break}break}a._index+=t.length-2}}return a._length=e.length,a}function A(e,t){const n=void 0===e.Y?1970:e.Y-("buddhist"===t?.calendar?543:0),[r,s]="h11"===t?.hour12?[0,11]:[1,12],[o,a]="h24"===t?.hour24?[1,24]:[0,23],i=(e,t,n)=>void 0===e||e>=t&&e<=n;return e._index>0&&e._length>0&&e._index===e._length&&e._match>0&&i(n,1,9999)&&i(e.M,1,12)&&i(e.D,1,(c=n,u=e.M??1,new Date(Date.UTC(c,u-(c<100?22800:0),0)).getUTCDate()))&&i(e.H,o,a)&&i(e.A,0,1)&&i(e.h,r,s)&&i(e.m,0,59)&&i(e.s,0,59)&&i(e.S,0,999)&&i(e.Z,-913,956);var c,u}function Z(e,t,n){return A(H(e,t,n),n)}function L(e,t,n){const r=H(e,t,n);return A(r,n)?(r.Y=r.Y?r.Y-("buddhist"===n?.calendar?543:0):1970,r.M=(r.M??1)-(r.Y<100?22801:1),r.D??=1,r.H=(r.H??0)%24||12*(r.A??0)+(r.h??0)%12,r.m??=0,r.s??=0,r.S??=0,l(n?.timeZone)||"Z"in r?new Date(Date.UTC(r.Y,r.M,r.D,r.H,r.m+(r.Z??0),r.s,r.S)):n?.timeZone?p(Date.UTC(r.Y,r.M,r.D,r.H,r.m,r.s,r.S),n.timeZone):new Date(r.Y,r.M,r.D,r.H,r.m,r.s,r.S)):new Date(NaN)}function k(e,t,n,r,s){return b(L(e,t,r),n,s)}function _(e,t,n){const r=D(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCMonth(r.getUTCMonth()+t),r.getUTCDate()<e.getUTCDate()?(r.setUTCDate(0),r):r):(r.setMonth(r.getMonth()+t),r.getDate()<e.getDate()?(r.setDate(0),r):r)}const s=h(e,r);s.month+=t,s.timezoneOffset=0;const o=new Date(c(s));return o.getUTCDate()<s.day&&o.setUTCDate(0),p(c({...s,year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate()}),r)}function j(e,t,n){return _(e,12*t,n)}function x(e,t,n){const r=D(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCDate(r.getUTCDate()+t),r):(r.setDate(r.getDate()+t),r)}const s=h(e,r);return s.day+=t,s.timezoneOffset=0,p(c(s),r)}function z(e,t){return new Date(e.getTime()+36e5*t)}function F(e,t){return new Date(e.getTime()+6e4*t)}function P(e,t){return new Date(e.getTime()+1e3*t)}function W(e,t){return new Date(e.getTime()+t)}const N=/^\[(.*)\]$/,J=(e,t)=>(e.F=Math.trunc(1e6*t),e),E=(e,t)=>(e.f=Math.trunc(1e3*t),J(e,1e3*Math.abs(t)%1/1e3)),I=(e,t)=>(e.S=Math.trunc(t),E(e,Math.abs(t)%1)),q=(e,t)=>(e.s=Math.trunc(t/1e3),I(e,Math.abs(t)%1e3)),B=(e,t)=>(e.m=Math.trunc(t/6e4),q(e,Math.abs(t)%6e4)),G=(e,t)=>(e.H=Math.trunc(t/36e5),B(e,Math.abs(t)%36e5)),K=(e,t,n=S)=>{const r=o(t).slice(1);return r.reduce((t,r)=>t+(t=>{if(t[0]in e){const r=e[t[0]]??0;return n.encode(`${(e=>e<0||0===e&&1/e==-1/0?"-":"")(r)}${String(Math.abs(r)).padStart(t.length,"0")}`)}return N.test(t)?t.replace(N,"$1"):t})(r),"")};class Q{constructor(e){this.time=e}toNanoseconds(){return{value:1e6*this.time,format:(e,t)=>K(J({},this.time),e,t),toParts:()=>({nanoseconds:Math.trunc(1e6*this.time)+0})}}toMicroseconds(){return{value:1e3*this.time,format:(e,t)=>K(E({},this.time),e,t),toParts:()=>({microseconds:Math.trunc(1e3*this.time)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMilliseconds(){return{value:this.time,format:(e,t)=>K(I({},this.time),e,t),toParts:()=>({milliseconds:Math.trunc(this.time)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toSeconds(){return{value:this.time/1e3,format:(e,t)=>K(q({},this.time),e,t),toParts:()=>({seconds:Math.trunc(this.time/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMinutes(){return{value:this.time/6e4,format:(e,t)=>K(B({},this.time),e,t),toParts:()=>({minutes:Math.trunc(this.time/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toHours(){return{value:this.time/36e5,format:(e,t)=>K(G({},this.time),e,t),toParts:()=>({hours:Math.trunc(this.time/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toDays(){return{value:this.time/864e5,format:(e,t)=>{return K((n={},r=this.time,n.D=Math.trunc(r/864e5),G(n,Math.abs(r)%864e5)),e,t);var n,r},toParts:()=>({days:Math.trunc(this.time/864e5)+0,hours:Math.trunc(this.time%864e5/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}}const R=(e,t)=>new Q(t.getTime()-e.getTime()),V=e=>!((e%4||!(e%100))&&e%400),X=(e,t)=>e.toDateString()===t.toDateString();export{Q as Duration,x as addDays,z as addHours,W as addMilliseconds,F as addMinutes,_ as addMonths,P as addSeconds,j as addYears,o as compile,b as format,V as isLeapYear,X as isSameDay,Z as isValid,L as parse,H as preparse,R as subtract,k as transform};
|
|
2
|
+
const e=/\\\[/g,t=/\\\]/g,n=/\uE000/g,r=/\uE001/g,s=/\[(?:[^[\]]|\[[^[\]]*])*]|([A-Za-z])\1*|\.{3}|./g,o=o=>{const a=o.replace(e,"").replace(t,"").match(s)??[];return[o,...a.map(e=>e.replace(n,"[").replace(r,"]"))]},a=new Map,i=e=>a.get(e)??(()=>{const t=new Intl.DateTimeFormat("en-US",{hour12:!1,weekday:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,timeZone:e});return e&&a.set(e,t),t})(),c=e=>Date.UTC(e.year,e.month-(e.year<100?22801:1),e.day,e.hour,e.minute,e.second,e.fractionalSecond+6e4*e.timezoneOffset),u=(e,t)=>e.formatToParts(t).reduce((e,{type:t,value:n})=>{switch(t){case"weekday":e[t]="SunMonTueWedThuFriSat".indexOf(n)/3;break;case"hour":e[t]=+n%24;break;case"year":case"month":case"day":case"minute":case"second":case"fractionalSecond":e[t]=+n}return e},{weekday:4,year:1970,month:1,day:1,hour:0,minute:0,second:0,fractionalSecond:0,timezoneOffset:0}),l=e=>"string"==typeof e&&"UTC"===e.toUpperCase(),h=(e,t)=>{if(l(t))return{weekday:e.getUTCDay(),year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate(),hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds(),fractionalSecond:e.getUTCMilliseconds(),timezoneOffset:0};const n=e.getTime(),r=u(i(t),n);return r.timezoneOffset=(n-c(r))/6e4,r};class d{constructor(e,t){this.parts=h(e,t),this.time=e.getTime()}getFullYear(){return this.parts.year}getMonth(){return this.parts.month-1}getDate(){return this.parts.day}getHours(){return this.parts.hour}getMinutes(){return this.parts.minute}getSeconds(){return this.parts.second}getMilliseconds(){return this.parts.fractionalSecond}getDay(){return this.parts.weekday}getTime(){return this.time}getTimezoneOffset(){return this.parts.timezoneOffset}}class m{}const g=(e,t)=>e.getFullYear()+("buddhist"===t?543:0);const M=new class extends m{YYYY(e,t){return`000${String(g(e,t.calendar))}`.slice(-4)}YY(e,t){return`0${String(g(e,t.calendar))}`.slice(-2)}Y(e,t){return String(g(e,t.calendar))}MMMM(e,t,n){return t.locale.getMonthList({style:"long",compiledObj:n})[e.getMonth()]??""}MMM(e,t,n){return t.locale.getMonthList({style:"short",compiledObj:n})[e.getMonth()]??""}MM(e){return`0${String(e.getMonth()+1)}`.slice(-2)}M(e){return String(e.getMonth()+1)}DD(e){return`0${String(e.getDate())}`.slice(-2)}D(e){return String(e.getDate())}HH(e,t){return`0${String(e.getHours()||("h24"===t.hour24?24:0))}`.slice(-2)}H(e,t){return String(e.getHours()||("h24"===t.hour24?24:0))}AA(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}A(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"})[+(e.getHours()>11)]??""}aa(e,t,n){return t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}a(e,t,n){return t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"})[+(e.getHours()>11)]??""}hh(e,t){return`0${String(e.getHours()%12||("h12"===t.hour12?12:0))}`.slice(-2)}h(e,t){return String(e.getHours()%12||("h12"===t.hour12?12:0))}mm(e){return`0${String(e.getMinutes())}`.slice(-2)}m(e){return String(e.getMinutes())}ss(e){return`0${String(e.getSeconds())}`.slice(-2)}s(e){return String(e.getSeconds())}SSS(e){return`00${String(e.getMilliseconds())}`.slice(-3)}SS(e){return`00${String(e.getMilliseconds())}`.slice(-3,-1)}S(e){return`00${String(e.getMilliseconds())}`.slice(-3,-2)}dddd(e,t,n){return t.locale.getDayOfWeekList({style:"long",compiledObj:n})[e.getDay()]??""}ddd(e,t,n){return t.locale.getDayOfWeekList({style:"short",compiledObj:n})[e.getDay()]??""}dd(e,t,n){return t.locale.getDayOfWeekList({style:"narrow",compiledObj:n})[e.getDay()]??""}Z(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}${`0${String(n%60)}`.slice(-2)}`}ZZ(e){const t=e.getTimezoneOffset(),n=Math.abs(t);return`${t>0?"-":"+"}${`0${String(n/60|0)}`.slice(-2)}:${`0${String(n%60)}`.slice(-2)}`}},f={MMMM:["January","February","March","April","May","June","July","August","September","October","November","December"],MMM:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dddd:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ddd:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dd:["Su","Mo","Tu","We","Th","Fr","Sa"],A:["AM","PM"],AA:["A.M.","P.M."],a:["am","pm"],aa:["a.m.","p.m."]};var y=new class{getLocale(){return"en"}getMonthList(e){return"long"===e.style?f.MMMM:f.MMM}getDayOfWeekList(e){return"long"===e.style?f.dddd:"short"===e.style?f.ddd:f.dd}getMeridiemList(e){return"long"===e.style?"lowercase"===e.case?f.aa:f.AA:"lowercase"===e.case?f.a:f.A}},S={encode:e=>e,decode:e=>e};const D=e=>!!e&&"object"==typeof e&&"zone_name"in e&&"gmt_offset"in e,p=(e,t)=>{const n=D(t)?t.zone_name:t;return new Date(e-((e,t)=>{const n=(()=>{try{return i(t)}catch{return}})(),r=new Set;if(n)for(let t=0;t<2;t++){const s=e-86400*t*1e3;let o=54822e3;do{const e=c(u(n,s-o))-s;if(0===e)return o;r.add(o),o+=e}while(!r.has(o));r.clear()}return NaN})(e,n))},T=/^\[(.*)\]$/;function b(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s=D(n?.timeZone)?n.timeZone.zone_name:n?.timeZone,a=s?new d(e,s):e,i={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??S,calendar:n?.calendar??"gregory",timeZone:n?.timeZone,locale:n?.locale??y},c=[...n?.plugins??[],M],u=i.numeral.encode;return r.reduce((e,t)=>e+((e,t)=>{for(const n of c)if(n[e])return u(n[e](a,i,t));return T.test(e)?e.replace(T,"$1"):e})(t,r),"")}class w{}const C=(e,t,n)=>{const r=e.exec(t)?.[0]??"";return{value:+r,length:r.length,token:n}},O=(e,t,n,r)=>{const[s,o]=n.ignoreCase?(()=>{const r=n.locale.getLocale();return[e.map(e=>e.toLocaleLowerCase(r)),t.toLocaleLowerCase(r)]})():[e,t];return s.reduce((e,t,n)=>t.length>e.length&&!o.indexOf(t)?{value:n,length:t.length,token:r}:e,{value:-1,length:0,token:r})},U=new Set(["Y","M","D","H","A","h","m","s","S","Z"]),Y=e=>U.has(e);const v=new class extends w{YYYY(e){return C(/^\d{4}/,e,"Y")}Y(e){return C(/^\d{1,4}/,e,"Y")}MMMM(e,t,n){const r=t.locale.getMonthList({style:"long",compiledObj:n}),s=O(r,e,t,"M");return s.value++,s}MMM(e,t,n){const r=t.locale.getMonthList({style:"short",compiledObj:n}),s=O(r,e,t,"M");return s.value++,s}MM(e){return C(/^\d\d/,e,"M")}M(e){return C(/^\d\d?/,e,"M")}DD(e){return C(/^\d\d/,e,"D")}D(e){return C(/^\d\d?/,e,"D")}HH(e){return C(/^\d\d/,e,"H")}H(e){return C(/^\d\d?/,e,"H")}AA(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"uppercase"});return O(r,e,t,"A")}A(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"uppercase"});return O(r,e,t,"A")}aa(e,t,n){const r=t.locale.getMeridiemList({style:"long",compiledObj:n,case:"lowercase"});return O(r,e,t,"A")}a(e,t,n){const r=t.locale.getMeridiemList({style:"short",compiledObj:n,case:"lowercase"});return O(r,e,t,"A")}hh(e){return C(/^\d\d/,e,"h")}h(e){return C(/^\d\d?/,e,"h")}mm(e){return C(/^\d\d/,e,"m")}m(e){return C(/^\d\d?/,e,"m")}ss(e){return C(/^\d\d/,e,"s")}s(e){return C(/^\d\d?/,e,"s")}SSS(e){return C(/^\d{1,3}/,e,"S")}SS(e){const t=C(/^\d\d?/,e,"S");return t.value*=10,t}S(e){const t=C(/^\d/,e,"S");return t.value*=100,t}Z(e){const t=C(/^[+-][01]\d[0-5]\d/,e,"Z");return t.value=-60*(t.value/100|0)-t.value%100,t}ZZ(e){const t=/^([+-][01]\d):([0-5]\d)/.exec(e)??["","",""],n=+(t[1]+t[2]);return{value:-60*(n/100|0)-n%100,length:t[0].length,token:"Z"}}},$=/^\[(.*)\]$/;function H(e,t,n){const r=("string"==typeof t?o(t):t).slice(1),s={hour12:n?.hour12??"h12",hour24:n?.hour24??"h23",numeral:n?.numeral??S,calendar:n?.calendar??"gregory",ignoreCase:n?.ignoreCase??!1,timeZone:(D(n?.timeZone)||"string"==typeof n?.timeZone)&&n.timeZone||void 0,locale:n?.locale??y},a={_index:0,_length:0,_match:0},i=[...n?.plugins??[],v],c=(e,t)=>{for(const n of i)if(n[e])return n[e](t,s,r)};e=s.numeral.decode(e);for(const t of r){const n=e.substring(a._index),r=c(t,n);if(r){if(!r.length)break;r.token&&Y(r.token)&&(a[r.token]=r.value+0),a._index+=r.length,a._match++}else if(t===n[0]||" "===t)a._index++;else{if(!$.test(t)||n.indexOf(t.replace($,"$1"))){if("..."===t){a._index=e.length;break}break}a._index+=t.length-2}}return a._length=e.length,a}const A=e=>!((e%4||!(e%100))&&e%400),Z=(e,t)=>e.toDateString()===t.toDateString(),L=(e,t,n)=>Date.UTC(e,t-(e<100?22800:0),n);function k(...e){const[t,n]=1===e.length?[e[0].getFullYear(),e[0].getMonth()+1]:e;return new Date(L(t,n,0)).getUTCDate()}const _=e=>{const t=new Date(e);return t.setUTCDate(t.getUTCDate()+(4-(t.getUTCDay()||7))),t};function F(...e){const[t,n,r]=1===e.length?[e[0].getFullYear(),e[0].getMonth()+1,e[0].getDate()]:e;return _(L(t,n-1,r)).getUTCFullYear()}function j(...e){const[t,n,r]=1===e.length?[e[0].getFullYear(),e[0].getMonth()+1,e[0].getDate()]:e,s=_(L(t,n-1,r));return Math.round((s.getTime()-_(L(s.getUTCFullYear(),0,4)).getTime())/864e5/7)+1}function x(e,t){const n=void 0===e.Y?1970:e.Y-("buddhist"===t?.calendar?543:0),[r,s]="h11"===t?.hour12?[0,11]:[1,12],[o,a]="h24"===t?.hour24?[1,24]:[0,23],i=(e,t,n)=>void 0===e||e>=t&&e<=n;return e._index>0&&e._length>0&&e._index===e._length&&e._match>0&&i(n,1,9999)&&i(e.M,1,12)&&i(e.D,1,k(n,e.M??1))&&i(e.H,o,a)&&i(e.A,0,1)&&i(e.h,r,s)&&i(e.m,0,59)&&i(e.s,0,59)&&i(e.S,0,999)&&i(e.Z,-913,956)}function z(e,t,n){return x(H(e,t,n),n)}function P(e,t,n){const r=H(e,t,n);return x(r,n)?(r.Y=r.Y?r.Y-("buddhist"===n?.calendar?543:0):1970,r.M=(r.M??1)-(r.Y<100?22801:1),r.D??=1,r.H=(r.H??0)%24||12*(r.A??0)+(r.h??0)%12,r.m??=0,r.s??=0,r.S??=0,l(n?.timeZone)||"Z"in r?new Date(Date.UTC(r.Y,r.M,r.D,r.H,r.m+(r.Z??0),r.s,r.S)):n?.timeZone?p(Date.UTC(r.Y,r.M,r.D,r.H,r.m,r.s,r.S),n.timeZone):new Date(r.Y,r.M,r.D,r.H,r.m,r.s,r.S)):new Date(NaN)}function W(e,t,n,r,s){return b(P(e,t,r),n,s)}function N(e,t,n){const r=D(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCMonth(r.getUTCMonth()+t),r.getUTCDate()<e.getUTCDate()?(r.setUTCDate(0),r):r):(r.setMonth(r.getMonth()+t),r.getDate()<e.getDate()?(r.setDate(0),r):r)}const s=h(e,r);s.month+=t,s.timezoneOffset=0;const o=new Date(c(s));return o.getUTCDate()<s.day&&o.setUTCDate(0),p(c({...s,year:o.getUTCFullYear(),month:o.getUTCMonth()+1,day:o.getUTCDate()}),r)}function J(e,t,n){return N(e,12*t,n)}function E(e,t,n){const r=D(n)?n.zone_name:n??void 0;if(!r||l(r)){const r=new Date(e.getTime());return l(n)?(r.setUTCDate(r.getUTCDate()+t),r):(r.setDate(r.getDate()+t),r)}const s=h(e,r);return s.day+=t,s.timezoneOffset=0,p(c(s),r)}function I(e,t){return new Date(e.getTime()+36e5*t)}function q(e,t){return new Date(e.getTime()+6e4*t)}function B(e,t){return new Date(e.getTime()+1e3*t)}function G(e,t){return new Date(e.getTime()+t)}const K=/^\[(.*)\]$/,Q=(e,t)=>(e.F=Math.trunc(1e6*t),e),R=(e,t)=>(e.f=Math.trunc(1e3*t),Q(e,1e3*Math.abs(t)%1/1e3)),V=(e,t)=>(e.S=Math.trunc(t),R(e,Math.abs(t)%1)),X=(e,t)=>(e.s=Math.trunc(t/1e3),V(e,Math.abs(t)%1e3)),ee=(e,t)=>(e.m=Math.trunc(t/6e4),X(e,Math.abs(t)%6e4)),te=(e,t)=>(e.H=Math.trunc(t/36e5),ee(e,Math.abs(t)%36e5)),ne=(e,t,n=S)=>{const r=o(t).slice(1);return r.reduce((t,r)=>t+(t=>{if(t[0]in e){const r=e[t[0]]??0;return n.encode(`${(e=>e<0||0===e&&1/e==-1/0?"-":"")(r)}${String(Math.abs(r)).padStart(t.length,"0")}`)}return K.test(t)?t.replace(K,"$1"):t})(r),"")};class re{constructor(e){this.time=e}toNanoseconds(){return{value:1e6*this.time,format:(e,t)=>ne(Q({},this.time),e,t),toParts:()=>({nanoseconds:Math.trunc(1e6*this.time)+0})}}toMicroseconds(){return{value:1e3*this.time,format:(e,t)=>ne(R({},this.time),e,t),toParts:()=>({microseconds:Math.trunc(1e3*this.time)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMilliseconds(){return{value:this.time,format:(e,t)=>ne(V({},this.time),e,t),toParts:()=>({milliseconds:Math.trunc(this.time)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toSeconds(){return{value:this.time/1e3,format:(e,t)=>ne(X({},this.time),e,t),toParts:()=>({seconds:Math.trunc(this.time/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toMinutes(){return{value:this.time/6e4,format:(e,t)=>ne(ee({},this.time),e,t),toParts:()=>({minutes:Math.trunc(this.time/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toHours(){return{value:this.time/36e5,format:(e,t)=>ne(te({},this.time),e,t),toParts:()=>({hours:Math.trunc(this.time/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}toDays(){return{value:this.time/864e5,format:(e,t)=>{return ne((n={},r=this.time,n.D=Math.trunc(r/864e5),te(n,Math.abs(r)%864e5)),e,t);var n,r},toParts:()=>({days:Math.trunc(this.time/864e5)+0,hours:Math.trunc(this.time%864e5/36e5)+0,minutes:Math.trunc(this.time%864e5%36e5/6e4)+0,seconds:Math.trunc(this.time%864e5%36e5%6e4/1e3)+0,milliseconds:Math.trunc(this.time%1e3)+0,microseconds:Math.trunc(1e3*this.time%1e3)+0,nanoseconds:Math.trunc(1e6*this.time%1e3)+0})}}}const se=(e,t)=>new re(t.getTime()-e.getTime());export{re as Duration,E as addDays,I as addHours,G as addMilliseconds,q as addMinutes,N as addMonths,B as addSeconds,J as addYears,o as compile,b as format,k as getDaysInMonth,j as getISOWeek,F as getISOWeekYear,A as isLeapYear,Z as isSameDay,z as isValid,P as parse,H as preparse,se as subtract,W as transform};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class t{}const s=new class extends t{Q(t){return String(1+(t.getMonth()/3|0))}};exports.formatter=s;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** @preserve Copyright (c) KNOWLEDGECODE - MIT License */
|
|
2
|
+
type CompiledObject = string[];
|
|
3
|
+
|
|
4
|
+
interface DateLike {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the year of the date.
|
|
7
|
+
*/
|
|
8
|
+
getFullYear(): number;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the month of the date (0-11).
|
|
11
|
+
*/
|
|
12
|
+
getMonth(): number;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the day of the month (1-31).
|
|
15
|
+
*/
|
|
16
|
+
getDate(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the hours of the date (0-23).
|
|
19
|
+
*/
|
|
20
|
+
getHours(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the minutes of the date (0-59).
|
|
23
|
+
*/
|
|
24
|
+
getMinutes(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the seconds of the date (0-59).
|
|
27
|
+
*/
|
|
28
|
+
getSeconds(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the milliseconds of the date (0-999).
|
|
31
|
+
*/
|
|
32
|
+
getMilliseconds(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the day of the week (0-6, where 0 is Sunday).
|
|
35
|
+
*/
|
|
36
|
+
getDay(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the time value in milliseconds since the Unix epoch (January 1, 1970).
|
|
39
|
+
*/
|
|
40
|
+
getTime(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the timezone offset in minutes from UTC.
|
|
43
|
+
*/
|
|
44
|
+
getTimezoneOffset(): number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LocaleOptions {
|
|
48
|
+
compiledObj: CompiledObject;
|
|
49
|
+
style: 'long' | 'short' | 'narrow';
|
|
50
|
+
case?: 'uppercase' | 'lowercase';
|
|
51
|
+
}
|
|
52
|
+
interface Locale {
|
|
53
|
+
getLocale: () => string;
|
|
54
|
+
getMonthList: (options: LocaleOptions) => string[];
|
|
55
|
+
getDayOfWeekList: (options: LocaleOptions) => string[];
|
|
56
|
+
getMeridiemList: (options: LocaleOptions) => string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface Numeral {
|
|
60
|
+
encode: (str: string) => string;
|
|
61
|
+
decode: (str: string) => string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface TimeZone {
|
|
65
|
+
zone_name: string;
|
|
66
|
+
gmt_offset: number[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface FormatterPluginOptions {
|
|
70
|
+
/**
|
|
71
|
+
* The hour format to use for formatting.
|
|
72
|
+
* This is used when the hour is in 12-hour format.
|
|
73
|
+
* It can be 'h11' for 11-hour format or 'h12' for 12-hour format.
|
|
74
|
+
*/
|
|
75
|
+
hour12: 'h11' | 'h12';
|
|
76
|
+
/**
|
|
77
|
+
* The hour format to use for formatting.
|
|
78
|
+
* This is used when the hour is in 24-hour format.
|
|
79
|
+
* It can be 'h23' for 23-hour format or 'h24' for 24-hour format.
|
|
80
|
+
*/
|
|
81
|
+
hour24: 'h23' | 'h24';
|
|
82
|
+
/**
|
|
83
|
+
* The numeral system to use for formatting numbers.
|
|
84
|
+
* This is an object that provides methods to encode and decode numbers in the specified numeral system.
|
|
85
|
+
*/
|
|
86
|
+
numeral: Numeral;
|
|
87
|
+
/**
|
|
88
|
+
* The calendar system to use for formatting dates.
|
|
89
|
+
* This can be 'buddhist' for Buddhist calendar or 'gregory' for Gregorian calendar.
|
|
90
|
+
*/
|
|
91
|
+
calendar: 'buddhist' | 'gregory';
|
|
92
|
+
/**
|
|
93
|
+
* The time zone to use for formatting dates and times.
|
|
94
|
+
* This can be a specific time zone object, an IANA time zone name, or 'UTC' to use Coordinated Universal Time.
|
|
95
|
+
* If not specified, it defaults to undefined, which means the local time zone will be used.
|
|
96
|
+
*/
|
|
97
|
+
timeZone: TimeZone | string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The locale to use for formatting dates and times.
|
|
100
|
+
* This is an object that provides methods to get localized month names, day names, and meridiems.
|
|
101
|
+
*/
|
|
102
|
+
locale: Locale;
|
|
103
|
+
}
|
|
104
|
+
declare abstract class FormatterPlugin {
|
|
105
|
+
[key: string]: ((d: DateLike, options: FormatterPluginOptions, compiledObj: CompiledObject) => string) | undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class Formatter extends FormatterPlugin {
|
|
109
|
+
Q(d: DateLike): string;
|
|
110
|
+
}
|
|
111
|
+
declare const formatter: Formatter;
|
|
112
|
+
|
|
113
|
+
export { formatter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class t{}const e=new class extends t{Q(t){return String(1+(t.getMonth()/3|0))}};export{e as formatter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class t{}const e=new class extends t{t(t){return String(Math.floor(t.getTime()/1e3))}T(t){return String(t.getTime())}};exports.formatter=e;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/** @preserve Copyright (c) KNOWLEDGECODE - MIT License */
|
|
2
|
+
type CompiledObject = string[];
|
|
3
|
+
|
|
4
|
+
interface DateLike {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the year of the date.
|
|
7
|
+
*/
|
|
8
|
+
getFullYear(): number;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the month of the date (0-11).
|
|
11
|
+
*/
|
|
12
|
+
getMonth(): number;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the day of the month (1-31).
|
|
15
|
+
*/
|
|
16
|
+
getDate(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the hours of the date (0-23).
|
|
19
|
+
*/
|
|
20
|
+
getHours(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the minutes of the date (0-59).
|
|
23
|
+
*/
|
|
24
|
+
getMinutes(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the seconds of the date (0-59).
|
|
27
|
+
*/
|
|
28
|
+
getSeconds(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the milliseconds of the date (0-999).
|
|
31
|
+
*/
|
|
32
|
+
getMilliseconds(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the day of the week (0-6, where 0 is Sunday).
|
|
35
|
+
*/
|
|
36
|
+
getDay(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the time value in milliseconds since the Unix epoch (January 1, 1970).
|
|
39
|
+
*/
|
|
40
|
+
getTime(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the timezone offset in minutes from UTC.
|
|
43
|
+
*/
|
|
44
|
+
getTimezoneOffset(): number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LocaleOptions {
|
|
48
|
+
compiledObj: CompiledObject;
|
|
49
|
+
style: 'long' | 'short' | 'narrow';
|
|
50
|
+
case?: 'uppercase' | 'lowercase';
|
|
51
|
+
}
|
|
52
|
+
interface Locale {
|
|
53
|
+
getLocale: () => string;
|
|
54
|
+
getMonthList: (options: LocaleOptions) => string[];
|
|
55
|
+
getDayOfWeekList: (options: LocaleOptions) => string[];
|
|
56
|
+
getMeridiemList: (options: LocaleOptions) => string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface Numeral {
|
|
60
|
+
encode: (str: string) => string;
|
|
61
|
+
decode: (str: string) => string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface TimeZone {
|
|
65
|
+
zone_name: string;
|
|
66
|
+
gmt_offset: number[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface FormatterPluginOptions {
|
|
70
|
+
/**
|
|
71
|
+
* The hour format to use for formatting.
|
|
72
|
+
* This is used when the hour is in 12-hour format.
|
|
73
|
+
* It can be 'h11' for 11-hour format or 'h12' for 12-hour format.
|
|
74
|
+
*/
|
|
75
|
+
hour12: 'h11' | 'h12';
|
|
76
|
+
/**
|
|
77
|
+
* The hour format to use for formatting.
|
|
78
|
+
* This is used when the hour is in 24-hour format.
|
|
79
|
+
* It can be 'h23' for 23-hour format or 'h24' for 24-hour format.
|
|
80
|
+
*/
|
|
81
|
+
hour24: 'h23' | 'h24';
|
|
82
|
+
/**
|
|
83
|
+
* The numeral system to use for formatting numbers.
|
|
84
|
+
* This is an object that provides methods to encode and decode numbers in the specified numeral system.
|
|
85
|
+
*/
|
|
86
|
+
numeral: Numeral;
|
|
87
|
+
/**
|
|
88
|
+
* The calendar system to use for formatting dates.
|
|
89
|
+
* This can be 'buddhist' for Buddhist calendar or 'gregory' for Gregorian calendar.
|
|
90
|
+
*/
|
|
91
|
+
calendar: 'buddhist' | 'gregory';
|
|
92
|
+
/**
|
|
93
|
+
* The time zone to use for formatting dates and times.
|
|
94
|
+
* This can be a specific time zone object, an IANA time zone name, or 'UTC' to use Coordinated Universal Time.
|
|
95
|
+
* If not specified, it defaults to undefined, which means the local time zone will be used.
|
|
96
|
+
*/
|
|
97
|
+
timeZone: TimeZone | string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The locale to use for formatting dates and times.
|
|
100
|
+
* This is an object that provides methods to get localized month names, day names, and meridiems.
|
|
101
|
+
*/
|
|
102
|
+
locale: Locale;
|
|
103
|
+
}
|
|
104
|
+
declare abstract class FormatterPlugin {
|
|
105
|
+
[key: string]: ((d: DateLike, options: FormatterPluginOptions, compiledObj: CompiledObject) => string) | undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class Formatter extends FormatterPlugin {
|
|
109
|
+
t(d: DateLike): string;
|
|
110
|
+
T(d: DateLike): string;
|
|
111
|
+
}
|
|
112
|
+
declare const formatter: Formatter;
|
|
113
|
+
|
|
114
|
+
export { formatter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class e{}const t=new class extends e{t(e){return String(Math.floor(e.getTime()/1e3))}T(e){return String(e.getTime())}};export{t as formatter};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";class t{}const e=(t,e,n)=>Date.UTC(t,e-(t<100?22800:0),n),n=t=>{const e=new Date(t);return e.setUTCDate(e.getUTCDate()+(4-(e.getUTCDay()||7))),e};const r=t=>function(...t){const[r,g,a]=1===t.length?[t[0].getFullYear(),t[0].getMonth()+1,t[0].getDate()]:t;return n(e(r,g-1,a)).getUTCFullYear()}(t.getFullYear(),t.getMonth()+1,t.getDate()),g=t=>function(...t){const[r,g,a]=1===t.length?[t[0].getFullYear(),t[0].getMonth()+1,t[0].getDate()]:t,l=n(e(r,g-1,a));return Math.round((l.getTime()-n(e(l.getUTCFullYear(),0,4)).getTime())/864e5/7)+1}(t.getFullYear(),t.getMonth()+1,t.getDate());const a=new class extends t{W(t){return String(g(t))}WW(t){return`0${String(g(t))}`.slice(-2)}GGGG(t){return`000${String(r(t))}`.slice(-4)}GG(t){return`0${String(r(t))}`.slice(-2)}G(t){return String(r(t))}};exports.formatter=a;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** @preserve Copyright (c) KNOWLEDGECODE - MIT License */
|
|
2
|
+
type CompiledObject = string[];
|
|
3
|
+
|
|
4
|
+
interface DateLike {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the year of the date.
|
|
7
|
+
*/
|
|
8
|
+
getFullYear(): number;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the month of the date (0-11).
|
|
11
|
+
*/
|
|
12
|
+
getMonth(): number;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the day of the month (1-31).
|
|
15
|
+
*/
|
|
16
|
+
getDate(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the hours of the date (0-23).
|
|
19
|
+
*/
|
|
20
|
+
getHours(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the minutes of the date (0-59).
|
|
23
|
+
*/
|
|
24
|
+
getMinutes(): number;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the seconds of the date (0-59).
|
|
27
|
+
*/
|
|
28
|
+
getSeconds(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the milliseconds of the date (0-999).
|
|
31
|
+
*/
|
|
32
|
+
getMilliseconds(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Returns the day of the week (0-6, where 0 is Sunday).
|
|
35
|
+
*/
|
|
36
|
+
getDay(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the time value in milliseconds since the Unix epoch (January 1, 1970).
|
|
39
|
+
*/
|
|
40
|
+
getTime(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the timezone offset in minutes from UTC.
|
|
43
|
+
*/
|
|
44
|
+
getTimezoneOffset(): number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface LocaleOptions {
|
|
48
|
+
compiledObj: CompiledObject;
|
|
49
|
+
style: 'long' | 'short' | 'narrow';
|
|
50
|
+
case?: 'uppercase' | 'lowercase';
|
|
51
|
+
}
|
|
52
|
+
interface Locale {
|
|
53
|
+
getLocale: () => string;
|
|
54
|
+
getMonthList: (options: LocaleOptions) => string[];
|
|
55
|
+
getDayOfWeekList: (options: LocaleOptions) => string[];
|
|
56
|
+
getMeridiemList: (options: LocaleOptions) => string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface Numeral {
|
|
60
|
+
encode: (str: string) => string;
|
|
61
|
+
decode: (str: string) => string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface TimeZone {
|
|
65
|
+
zone_name: string;
|
|
66
|
+
gmt_offset: number[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface FormatterPluginOptions {
|
|
70
|
+
/**
|
|
71
|
+
* The hour format to use for formatting.
|
|
72
|
+
* This is used when the hour is in 12-hour format.
|
|
73
|
+
* It can be 'h11' for 11-hour format or 'h12' for 12-hour format.
|
|
74
|
+
*/
|
|
75
|
+
hour12: 'h11' | 'h12';
|
|
76
|
+
/**
|
|
77
|
+
* The hour format to use for formatting.
|
|
78
|
+
* This is used when the hour is in 24-hour format.
|
|
79
|
+
* It can be 'h23' for 23-hour format or 'h24' for 24-hour format.
|
|
80
|
+
*/
|
|
81
|
+
hour24: 'h23' | 'h24';
|
|
82
|
+
/**
|
|
83
|
+
* The numeral system to use for formatting numbers.
|
|
84
|
+
* This is an object that provides methods to encode and decode numbers in the specified numeral system.
|
|
85
|
+
*/
|
|
86
|
+
numeral: Numeral;
|
|
87
|
+
/**
|
|
88
|
+
* The calendar system to use for formatting dates.
|
|
89
|
+
* This can be 'buddhist' for Buddhist calendar or 'gregory' for Gregorian calendar.
|
|
90
|
+
*/
|
|
91
|
+
calendar: 'buddhist' | 'gregory';
|
|
92
|
+
/**
|
|
93
|
+
* The time zone to use for formatting dates and times.
|
|
94
|
+
* This can be a specific time zone object, an IANA time zone name, or 'UTC' to use Coordinated Universal Time.
|
|
95
|
+
* If not specified, it defaults to undefined, which means the local time zone will be used.
|
|
96
|
+
*/
|
|
97
|
+
timeZone: TimeZone | string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* The locale to use for formatting dates and times.
|
|
100
|
+
* This is an object that provides methods to get localized month names, day names, and meridiems.
|
|
101
|
+
*/
|
|
102
|
+
locale: Locale;
|
|
103
|
+
}
|
|
104
|
+
declare abstract class FormatterPlugin {
|
|
105
|
+
[key: string]: ((d: DateLike, options: FormatterPluginOptions, compiledObj: CompiledObject) => string) | undefined;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
declare class Formatter extends FormatterPlugin {
|
|
109
|
+
W(d: DateLike): string;
|
|
110
|
+
WW(d: DateLike): string;
|
|
111
|
+
GGGG(d: DateLike): string;
|
|
112
|
+
GG(d: DateLike): string;
|
|
113
|
+
G(d: DateLike): string;
|
|
114
|
+
}
|
|
115
|
+
declare const formatter: Formatter;
|
|
116
|
+
|
|
117
|
+
export { formatter };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class t{}const e=(t,e,n)=>Date.UTC(t,e-(t<100?22800:0),n),n=t=>{const e=new Date(t);return e.setUTCDate(e.getUTCDate()+(4-(e.getUTCDay()||7))),e};const r=t=>function(...t){const[r,g,l]=1===t.length?[t[0].getFullYear(),t[0].getMonth()+1,t[0].getDate()]:t;return n(e(r,g-1,l)).getUTCFullYear()}(t.getFullYear(),t.getMonth()+1,t.getDate()),g=t=>function(...t){const[r,g,l]=1===t.length?[t[0].getFullYear(),t[0].getMonth()+1,t[0].getDate()]:t,a=n(e(r,g-1,l));return Math.round((a.getTime()-n(e(a.getUTCFullYear(),0,4)).getTime())/864e5/7)+1}(t.getFullYear(),t.getMonth()+1,t.getDate());const l=new class extends t{W(t){return String(g(t))}WW(t){return`0${String(g(t))}`.slice(-2)}GGGG(t){return`000${String(r(t))}`.slice(-4)}GG(t){return`0${String(r(t))}`.slice(-2)}G(t){return String(r(t))}};export{l as formatter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a={"Acre Standard Time":"ACT","Acre Summer Time":"ACST","Afghanistan Time":"AFT","Alaska Daylight Time":"AKDT","Alaska Standard Time":"AKST","Almaty Standard Time":"ALMT","Almaty Summer Time":"ALMST","Amazon Standard Time":"AMT","Amazon Summer Time":"AMST","American Samoa Standard Time":"SST","Anadyr Standard Time":"ANAT","Anadyr Summer Time":"ANAST","Aqtau Standard Time":"AQTT","Aqtau Summer Time":"AQTST","Aqtobe Standard Time":"AQTT","Aqtobe Summer Time":"AQTST","Arabian Daylight Time":"ADT","Arabian Standard Time":"AST","Argentina Standard Time":"ART","Argentina Summer Time":"ARST","Armenia Standard Time":"AMT","Armenia Summer Time":"AMST","Atlantic Daylight Time":"ADT","Atlantic Standard Time":"AST","Australian Central Daylight Time":"ACDT","Australian Central Standard Time":"ACST","Australian Central Western Daylight Time":"ACWDT","Australian Central Western Standard Time":"ACWST","Australian Eastern Daylight Time":"AEDT","Australian Eastern Standard Time":"AEST","Australian Western Daylight Time":"AWDT","Australian Western Standard Time":"AWST","Azerbaijan Standard Time":"AZT","Azerbaijan Summer Time":"AZST","Azores Standard Time":"AZOT","Azores Summer Time":"AZOST","Bangladesh Standard Time":"BST","Bangladesh Summer Time":"BDST","Bhutan Time":"BTT","Bolivia Time":"BOT","Brasilia Standard Time":"BRT","Brasilia Summer Time":"BRST","British Summer Time":"BST","Brunei Time":"BNT","Cape Verde Standard Time":"CVT","Casey Time":"CAST","Central Africa Time":"CAT","Central Daylight Time":"CDT","Central European Standard Time":"CET","Central European Summer Time":"CEST","Central Indonesia Time":"WITA","Central Standard Time":"CST","Chamorro Standard Time":"ChST","Chatham Daylight Time":"CHADT","Chatham Standard Time":"CHAST","Chile Standard Time":"CLT","Chile Summer Time":"CLST","China Daylight Time":"CDT","China Standard Time":"CST","Christmas Island Time":"CXT","Chuuk Time":"CHUT","Cocos Islands Time":"CCT","Colombia Standard Time":"COT","Colombia Summer Time":"COST","Cook Islands Standard Time":"CKT","Cook Islands Summer Time":"CKST","Coordinated Universal Time":"UTC","Cuba Daylight Time":"CDT","Cuba Standard Time":"CST","Davis Time":"DAVT","Dumont d’Urville Time":"DDUT","East Africa Time":"EAT","East Greenland Standard Time":"EGT","East Greenland Summer Time":"EGST","East Kazakhstan Time":"ALMT","Easter Island Standard Time":"EAST","Easter Island Summer Time":"EASST","Eastern Daylight Time":"EDT","Eastern European Standard Time":"EET","Eastern European Summer Time":"EEST","Eastern Indonesia Time":"WIT","Eastern Standard Time":"EST","Ecuador Time":"ECT","Falkland Islands Standard Time":"
|
|
1
|
+
"use strict";var a={"Acre Standard Time":"ACT","Acre Summer Time":"ACST","Afghanistan Time":"AFT","Alaska Daylight Time":"AKDT","Alaska Standard Time":"AKST","Almaty Standard Time":"ALMT","Almaty Summer Time":"ALMST","Amazon Standard Time":"AMT","Amazon Summer Time":"AMST","American Samoa Standard Time":"SST","Anadyr Standard Time":"ANAT","Anadyr Summer Time":"ANAST","Apia Daylight Time":"WSDT","Apia Standard Time":"WSST","Aqtau Standard Time":"AQTT","Aqtau Summer Time":"AQTST","Aqtobe Standard Time":"AQTT","Aqtobe Summer Time":"AQTST","Arabian Daylight Time":"ADT","Arabian Standard Time":"AST","Argentina Standard Time":"ART","Argentina Summer Time":"ARST","Armenia Standard Time":"AMT","Armenia Summer Time":"AMST","Atlantic Daylight Time":"ADT","Atlantic Standard Time":"AST","Australian Central Daylight Time":"ACDT","Australian Central Standard Time":"ACST","Australian Central Western Daylight Time":"ACWDT","Australian Central Western Standard Time":"ACWST","Australian Eastern Daylight Time":"AEDT","Australian Eastern Standard Time":"AEST","Australian Western Daylight Time":"AWDT","Australian Western Standard Time":"AWST","Azerbaijan Standard Time":"AZT","Azerbaijan Summer Time":"AZST","Azores Standard Time":"AZOT","Azores Summer Time":"AZOST","Bangladesh Standard Time":"BST","Bangladesh Summer Time":"BDST","Bhutan Time":"BTT","Bolivia Time":"BOT","Brasilia Standard Time":"BRT","Brasilia Summer Time":"BRST","British Summer Time":"BST","Brunei Darussalam Time":"BNT","Brunei Time":"BNT","Cape Verde Standard Time":"CVT","Casey Time":"CAST","Central Africa Time":"CAT","Central Daylight Time":"CDT","Central European Standard Time":"CET","Central European Summer Time":"CEST","Central Indonesia Time":"WITA","Central Standard Time":"CST","Chamorro Standard Time":"ChST","Chatham Daylight Time":"CHADT","Chatham Standard Time":"CHAST","Chile Standard Time":"CLT","Chile Summer Time":"CLST","China Daylight Time":"CDT","China Standard Time":"CST","Choibalsan Standard Time":"CHOT","Choibalsan Summer Time":"CHOST","Christmas Island Time":"CXT","Chuuk Time":"CHUT","Cocos Islands Time":"CCT","Colombia Standard Time":"COT","Colombia Summer Time":"COST","Cook Islands Half Summer Time":"CKHST","Cook Islands Standard Time":"CKT","Cook Islands Summer Time":"CKST","Coordinated Universal Time":"UTC","Cuba Daylight Time":"CDT","Cuba Standard Time":"CST","Davis Time":"DAVT","Dumont d’Urville Time":"DDUT","Dumont-d’Urville Time":"DDUT","East Africa Time":"EAT","East Greenland Standard Time":"EGT","East Greenland Summer Time":"EGST","East Kazakhstan Time":"ALMT","East Timor Time":"TLT","Easter Island Standard Time":"EAST","Easter Island Summer Time":"EASST","Eastern Daylight Time":"EDT","Eastern European Standard Time":"EET","Eastern European Summer Time":"EEST","Eastern Indonesia Time":"WIT","Eastern Standard Time":"EST","Ecuador Time":"ECT","Falkland Islands Standard Time":"FKT","Falkland Islands Summer Time":"FKST","Fernando de Noronha Standard Time":"FNT","Fernando de Noronha Summer Time":"FNST","Fiji Standard Time":"FJT","Fiji Summer Time":"FJST","French Guiana Time":"GFT","French Southern & Antarctic Time":"TFT","Further-eastern European Time":"FET","Galapagos Time":"GALT","Gambier Time":"GAMT","Georgia Standard Time":"GET","Georgia Summer Time":"GEST","Gilbert Islands Time":"GILT","Greenland Standard Time":"WGT","Greenland Summer Time":"WGST","Greenwich Mean Time":"GMT","Guam Standard Time":"ChST","Gulf Standard Time":"GST","Guyana Time":"GYT","Hawaii-Aleutian Daylight Time":"HDT","Hawaii-Aleutian Standard Time":"HST","Hong Kong Standard Time":"HKT","Hong Kong Summer Time":"HKST","Hovd Standard Time":"HOVT","Hovd Summer Time":"HOVST","India Standard Time":"IST","Indian Ocean Time":"IOT","Indochina Time":"ICT","Iran Daylight Time":"IRDT","Iran Standard Time":"IRST","Irish Standard Time":"IST","Irkutsk Standard Time":"IRKT","Irkutsk Summer Time":"IRKST","Israel Daylight Time":"IDT","Israel Standard Time":"IST","Japan Standard Time":"JST","Kamchatka Standard Time":"PETT","Kamchatka Summer Time":"PETST","Kazakhstan Time":"KZT","Khovd Standard Time":"HOVT","Khovd Summer Time":"HOVST","Korean Daylight Time":"KDT","Korean Standard Time":"KST","Kosrae Time":"KOST","Krasnoyarsk Standard Time":"KRAT","Krasnoyarsk Summer Time":"KRAST","Kyrgyzstan Time":"KGT","Kyzylorda Standard Time":"QYZT","Kyzylorda Summer Time":"QYZST","Lanka Time":"LKT","Line Islands Time":"LINT","Lord Howe Daylight Time":"LHDT","Lord Howe Standard Time":"LHST","Macao Standard Time":"CST","Macao Summer Time":"CDT","Magadan Standard Time":"MAGT","Magadan Summer Time":"MAGST","Malaysia Time":"MYT","Maldives Time":"MVT","Marquesas Time":"MART","Marshall Islands Time":"MHT","Mauritius Standard Time":"MUT","Mauritius Summer Time":"MUST","Mawson Time":"MAWT","Mexican Pacific Daylight Time":"PDT","Mexican Pacific Standard Time":"PST","Moscow Standard Time":"MSK","Moscow Summer Time":"MSD","Mountain Daylight Time":"MDT","Mountain Standard Time":"MST","Myanmar Time":"MMT","Nauru Time":"NRT","Nepal Time":"NPT","New Caledonia Standard Time":"NCT","New Caledonia Summer Time":"NCST","New Zealand Daylight Time":"NZDT","New Zealand Standard Time":"NZST","Newfoundland Daylight Time":"NDT","Newfoundland Standard Time":"NST","Niue Time":"NUT","Norfolk Island Daylight Time":"NFDT","Norfolk Island Standard Time":"NFT","North Korea Time":"KST","North Mariana Islands Time":"ChST","Northern Mariana Islands Time":"ChST","Novosibirsk Standard Time":"NOVT","Novosibirsk Summer Time":"NOVST","Omsk Standard Time":"OMST","Omsk Summer Time":"OMSST","Pacific Daylight Time":"PDT","Pacific Standard Time":"PST","Pakistan Standard Time":"PKT","Pakistan Summer Time":"PKST","Palau Time":"PWT","Papua New Guinea Time":"PGT","Paraguay Standard Time":"PYT","Paraguay Summer Time":"PYST","Peru Standard Time":"PET","Peru Summer Time":"PEST","Petropavlovsk-Kamchatski Standard Time":"PETT","Petropavlovsk-Kamchatski Summer Time":"PETST","Philippine Standard Time":"PHT","Philippine Summer Time":"PHST","Phoenix Islands Time":"PHOT","Pitcairn Time":"PST","Pohnpei Time":"PONT","Ponape Time":"PONT","Pyongyang Time":"KST","Qyzylorda Standard Time":"QYZT","Qyzylorda Summer Time":"QYZST","Réunion Time":"RET","Rothera Time":"ROTT","Sakhalin Standard Time":"SAKT","Sakhalin Summer Time":"SAKST","Samara Standard Time":"SAMT","Samara Summer Time":"SAMST","Samoa Daylight Time":"SDT","Samoa Standard Time":"SST","Seychelles Time":"SCT","Singapore Standard Time":"SGT","Solomon Islands Time":"SBT","South Africa Standard Time":"SAST","South Georgia Time":"GST","St. Pierre & Miquelon Daylight Time":"PMDT","St. Pierre & Miquelon Standard Time":"PMST","Suriname Time":"SRT","Syowa Time":"SYOT","Tahiti Time":"TAHT","Taipei Daylight Time":"CDT","Taipei Standard Time":"CST","Taiwan Daylight Time":"CDT","Taiwan Standard Time":"CST","Tajikistan Time":"TJT","Timor-Leste Time":"TLT","Tokelau Time":"TKT","Tonga Standard Time":"TOT","Tonga Summer Time":"TOST","Türkiye Standard Time":"TRT","Türkiye Summer Time":"TRST","Turkmenistan Standard Time":"TMT","Tuvalu Time":"TVT","Ulaanbaatar Standard Time":"ULAT","Ulaanbaatar Summer Time":"ULAST","Uruguay Standard Time":"UYT","Uruguay Summer Time":"UYST","Uzbekistan Standard Time":"UZT","Uzbekistan Summer Time":"UZST","Vanuatu Standard Time":"VUT","Vanuatu Summer Time":"VUST","Venezuela Time":"VET","Vladivostok Standard Time":"VLAT","Vladivostok Summer Time":"VLAST","Volgograd Standard Time":"VOLT","Volgograd Summer Time":"VOLST","Vostok Time":"VOST","Wake Island Time":"WAKT","Wallis & Futuna Time":"WFT","West Africa Standard Time":"WAT","West Africa Summer Time":"WAST","West Africa Time":"WAT","West Greenland Standard Time":"WGT","West Greenland Summer Time":"WGST","West Kazakhstan Time":"AQTT","Western Argentina Standard Time":"WART","Western Argentina Summer Time":"WARST","Western European Standard Time":"WET","Western European Summer Time":"WEST","Western Indonesia Time":"WIB","Yakutsk Standard Time":"YAKT","Yakutsk Summer Time":"YAKST","Yekaterinburg Standard Time":"YEKT","Yekaterinburg Summer Time":"YEKST","Yukon Time":"YT"};class T{}const e=a=>!!a&&"object"==typeof a&&"zone_name"in a&&"gmt_offset"in a,i=(a,T)=>{const e=new Intl.DateTimeFormat("en-US",{timeZone:T??void 0,timeZoneName:"long"}).formatToParts(a);return e.find(a=>"timeZoneName"===a.type)?.value.replace(/^GMT[+-].+$/,"")??""};const m=new class extends T{z(T,m){const r=e(m.timeZone)?m.timeZone.zone_name:m.timeZone;return((T,e)=>a[i(T,e)]||"")(T.getTime(),r)}zz(a,T){const m=e(T.timeZone)?T.timeZone.zone_name:T.timeZone;return i(a.getTime(),m)}};exports.formatter=m;
|
package/dist/plugins/zonename.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var a={"Acre Standard Time":"ACT","Acre Summer Time":"ACST","Afghanistan Time":"AFT","Alaska Daylight Time":"AKDT","Alaska Standard Time":"AKST","Almaty Standard Time":"ALMT","Almaty Summer Time":"ALMST","Amazon Standard Time":"AMT","Amazon Summer Time":"AMST","American Samoa Standard Time":"SST","Anadyr Standard Time":"ANAT","Anadyr Summer Time":"ANAST","Aqtau Standard Time":"AQTT","Aqtau Summer Time":"AQTST","Aqtobe Standard Time":"AQTT","Aqtobe Summer Time":"AQTST","Arabian Daylight Time":"ADT","Arabian Standard Time":"AST","Argentina Standard Time":"ART","Argentina Summer Time":"ARST","Armenia Standard Time":"AMT","Armenia Summer Time":"AMST","Atlantic Daylight Time":"ADT","Atlantic Standard Time":"AST","Australian Central Daylight Time":"ACDT","Australian Central Standard Time":"ACST","Australian Central Western Daylight Time":"ACWDT","Australian Central Western Standard Time":"ACWST","Australian Eastern Daylight Time":"AEDT","Australian Eastern Standard Time":"AEST","Australian Western Daylight Time":"AWDT","Australian Western Standard Time":"AWST","Azerbaijan Standard Time":"AZT","Azerbaijan Summer Time":"AZST","Azores Standard Time":"AZOT","Azores Summer Time":"AZOST","Bangladesh Standard Time":"BST","Bangladesh Summer Time":"BDST","Bhutan Time":"BTT","Bolivia Time":"BOT","Brasilia Standard Time":"BRT","Brasilia Summer Time":"BRST","British Summer Time":"BST","Brunei Time":"BNT","Cape Verde Standard Time":"CVT","Casey Time":"CAST","Central Africa Time":"CAT","Central Daylight Time":"CDT","Central European Standard Time":"CET","Central European Summer Time":"CEST","Central Indonesia Time":"WITA","Central Standard Time":"CST","Chamorro Standard Time":"ChST","Chatham Daylight Time":"CHADT","Chatham Standard Time":"CHAST","Chile Standard Time":"CLT","Chile Summer Time":"CLST","China Daylight Time":"CDT","China Standard Time":"CST","Christmas Island Time":"CXT","Chuuk Time":"CHUT","Cocos Islands Time":"CCT","Colombia Standard Time":"COT","Colombia Summer Time":"COST","Cook Islands Standard Time":"CKT","Cook Islands Summer Time":"CKST","Coordinated Universal Time":"UTC","Cuba Daylight Time":"CDT","Cuba Standard Time":"CST","Davis Time":"DAVT","Dumont d’Urville Time":"DDUT","East Africa Time":"EAT","East Greenland Standard Time":"EGT","East Greenland Summer Time":"EGST","East Kazakhstan Time":"ALMT","Easter Island Standard Time":"EAST","Easter Island Summer Time":"EASST","Eastern Daylight Time":"EDT","Eastern European Standard Time":"EET","Eastern European Summer Time":"EEST","Eastern Indonesia Time":"WIT","Eastern Standard Time":"EST","Ecuador Time":"ECT","Falkland Islands Standard Time":"
|
|
1
|
+
var a={"Acre Standard Time":"ACT","Acre Summer Time":"ACST","Afghanistan Time":"AFT","Alaska Daylight Time":"AKDT","Alaska Standard Time":"AKST","Almaty Standard Time":"ALMT","Almaty Summer Time":"ALMST","Amazon Standard Time":"AMT","Amazon Summer Time":"AMST","American Samoa Standard Time":"SST","Anadyr Standard Time":"ANAT","Anadyr Summer Time":"ANAST","Apia Daylight Time":"WSDT","Apia Standard Time":"WSST","Aqtau Standard Time":"AQTT","Aqtau Summer Time":"AQTST","Aqtobe Standard Time":"AQTT","Aqtobe Summer Time":"AQTST","Arabian Daylight Time":"ADT","Arabian Standard Time":"AST","Argentina Standard Time":"ART","Argentina Summer Time":"ARST","Armenia Standard Time":"AMT","Armenia Summer Time":"AMST","Atlantic Daylight Time":"ADT","Atlantic Standard Time":"AST","Australian Central Daylight Time":"ACDT","Australian Central Standard Time":"ACST","Australian Central Western Daylight Time":"ACWDT","Australian Central Western Standard Time":"ACWST","Australian Eastern Daylight Time":"AEDT","Australian Eastern Standard Time":"AEST","Australian Western Daylight Time":"AWDT","Australian Western Standard Time":"AWST","Azerbaijan Standard Time":"AZT","Azerbaijan Summer Time":"AZST","Azores Standard Time":"AZOT","Azores Summer Time":"AZOST","Bangladesh Standard Time":"BST","Bangladesh Summer Time":"BDST","Bhutan Time":"BTT","Bolivia Time":"BOT","Brasilia Standard Time":"BRT","Brasilia Summer Time":"BRST","British Summer Time":"BST","Brunei Darussalam Time":"BNT","Brunei Time":"BNT","Cape Verde Standard Time":"CVT","Casey Time":"CAST","Central Africa Time":"CAT","Central Daylight Time":"CDT","Central European Standard Time":"CET","Central European Summer Time":"CEST","Central Indonesia Time":"WITA","Central Standard Time":"CST","Chamorro Standard Time":"ChST","Chatham Daylight Time":"CHADT","Chatham Standard Time":"CHAST","Chile Standard Time":"CLT","Chile Summer Time":"CLST","China Daylight Time":"CDT","China Standard Time":"CST","Choibalsan Standard Time":"CHOT","Choibalsan Summer Time":"CHOST","Christmas Island Time":"CXT","Chuuk Time":"CHUT","Cocos Islands Time":"CCT","Colombia Standard Time":"COT","Colombia Summer Time":"COST","Cook Islands Half Summer Time":"CKHST","Cook Islands Standard Time":"CKT","Cook Islands Summer Time":"CKST","Coordinated Universal Time":"UTC","Cuba Daylight Time":"CDT","Cuba Standard Time":"CST","Davis Time":"DAVT","Dumont d’Urville Time":"DDUT","Dumont-d’Urville Time":"DDUT","East Africa Time":"EAT","East Greenland Standard Time":"EGT","East Greenland Summer Time":"EGST","East Kazakhstan Time":"ALMT","East Timor Time":"TLT","Easter Island Standard Time":"EAST","Easter Island Summer Time":"EASST","Eastern Daylight Time":"EDT","Eastern European Standard Time":"EET","Eastern European Summer Time":"EEST","Eastern Indonesia Time":"WIT","Eastern Standard Time":"EST","Ecuador Time":"ECT","Falkland Islands Standard Time":"FKT","Falkland Islands Summer Time":"FKST","Fernando de Noronha Standard Time":"FNT","Fernando de Noronha Summer Time":"FNST","Fiji Standard Time":"FJT","Fiji Summer Time":"FJST","French Guiana Time":"GFT","French Southern & Antarctic Time":"TFT","Further-eastern European Time":"FET","Galapagos Time":"GALT","Gambier Time":"GAMT","Georgia Standard Time":"GET","Georgia Summer Time":"GEST","Gilbert Islands Time":"GILT","Greenland Standard Time":"WGT","Greenland Summer Time":"WGST","Greenwich Mean Time":"GMT","Guam Standard Time":"ChST","Gulf Standard Time":"GST","Guyana Time":"GYT","Hawaii-Aleutian Daylight Time":"HDT","Hawaii-Aleutian Standard Time":"HST","Hong Kong Standard Time":"HKT","Hong Kong Summer Time":"HKST","Hovd Standard Time":"HOVT","Hovd Summer Time":"HOVST","India Standard Time":"IST","Indian Ocean Time":"IOT","Indochina Time":"ICT","Iran Daylight Time":"IRDT","Iran Standard Time":"IRST","Irish Standard Time":"IST","Irkutsk Standard Time":"IRKT","Irkutsk Summer Time":"IRKST","Israel Daylight Time":"IDT","Israel Standard Time":"IST","Japan Standard Time":"JST","Kamchatka Standard Time":"PETT","Kamchatka Summer Time":"PETST","Kazakhstan Time":"KZT","Khovd Standard Time":"HOVT","Khovd Summer Time":"HOVST","Korean Daylight Time":"KDT","Korean Standard Time":"KST","Kosrae Time":"KOST","Krasnoyarsk Standard Time":"KRAT","Krasnoyarsk Summer Time":"KRAST","Kyrgyzstan Time":"KGT","Kyzylorda Standard Time":"QYZT","Kyzylorda Summer Time":"QYZST","Lanka Time":"LKT","Line Islands Time":"LINT","Lord Howe Daylight Time":"LHDT","Lord Howe Standard Time":"LHST","Macao Standard Time":"CST","Macao Summer Time":"CDT","Magadan Standard Time":"MAGT","Magadan Summer Time":"MAGST","Malaysia Time":"MYT","Maldives Time":"MVT","Marquesas Time":"MART","Marshall Islands Time":"MHT","Mauritius Standard Time":"MUT","Mauritius Summer Time":"MUST","Mawson Time":"MAWT","Mexican Pacific Daylight Time":"PDT","Mexican Pacific Standard Time":"PST","Moscow Standard Time":"MSK","Moscow Summer Time":"MSD","Mountain Daylight Time":"MDT","Mountain Standard Time":"MST","Myanmar Time":"MMT","Nauru Time":"NRT","Nepal Time":"NPT","New Caledonia Standard Time":"NCT","New Caledonia Summer Time":"NCST","New Zealand Daylight Time":"NZDT","New Zealand Standard Time":"NZST","Newfoundland Daylight Time":"NDT","Newfoundland Standard Time":"NST","Niue Time":"NUT","Norfolk Island Daylight Time":"NFDT","Norfolk Island Standard Time":"NFT","North Korea Time":"KST","North Mariana Islands Time":"ChST","Northern Mariana Islands Time":"ChST","Novosibirsk Standard Time":"NOVT","Novosibirsk Summer Time":"NOVST","Omsk Standard Time":"OMST","Omsk Summer Time":"OMSST","Pacific Daylight Time":"PDT","Pacific Standard Time":"PST","Pakistan Standard Time":"PKT","Pakistan Summer Time":"PKST","Palau Time":"PWT","Papua New Guinea Time":"PGT","Paraguay Standard Time":"PYT","Paraguay Summer Time":"PYST","Peru Standard Time":"PET","Peru Summer Time":"PEST","Petropavlovsk-Kamchatski Standard Time":"PETT","Petropavlovsk-Kamchatski Summer Time":"PETST","Philippine Standard Time":"PHT","Philippine Summer Time":"PHST","Phoenix Islands Time":"PHOT","Pitcairn Time":"PST","Pohnpei Time":"PONT","Ponape Time":"PONT","Pyongyang Time":"KST","Qyzylorda Standard Time":"QYZT","Qyzylorda Summer Time":"QYZST","Réunion Time":"RET","Rothera Time":"ROTT","Sakhalin Standard Time":"SAKT","Sakhalin Summer Time":"SAKST","Samara Standard Time":"SAMT","Samara Summer Time":"SAMST","Samoa Daylight Time":"SDT","Samoa Standard Time":"SST","Seychelles Time":"SCT","Singapore Standard Time":"SGT","Solomon Islands Time":"SBT","South Africa Standard Time":"SAST","South Georgia Time":"GST","St. Pierre & Miquelon Daylight Time":"PMDT","St. Pierre & Miquelon Standard Time":"PMST","Suriname Time":"SRT","Syowa Time":"SYOT","Tahiti Time":"TAHT","Taipei Daylight Time":"CDT","Taipei Standard Time":"CST","Taiwan Daylight Time":"CDT","Taiwan Standard Time":"CST","Tajikistan Time":"TJT","Timor-Leste Time":"TLT","Tokelau Time":"TKT","Tonga Standard Time":"TOT","Tonga Summer Time":"TOST","Türkiye Standard Time":"TRT","Türkiye Summer Time":"TRST","Turkmenistan Standard Time":"TMT","Tuvalu Time":"TVT","Ulaanbaatar Standard Time":"ULAT","Ulaanbaatar Summer Time":"ULAST","Uruguay Standard Time":"UYT","Uruguay Summer Time":"UYST","Uzbekistan Standard Time":"UZT","Uzbekistan Summer Time":"UZST","Vanuatu Standard Time":"VUT","Vanuatu Summer Time":"VUST","Venezuela Time":"VET","Vladivostok Standard Time":"VLAT","Vladivostok Summer Time":"VLAST","Volgograd Standard Time":"VOLT","Volgograd Summer Time":"VOLST","Vostok Time":"VOST","Wake Island Time":"WAKT","Wallis & Futuna Time":"WFT","West Africa Standard Time":"WAT","West Africa Summer Time":"WAST","West Africa Time":"WAT","West Greenland Standard Time":"WGT","West Greenland Summer Time":"WGST","West Kazakhstan Time":"AQTT","Western Argentina Standard Time":"WART","Western Argentina Summer Time":"WARST","Western European Standard Time":"WET","Western European Summer Time":"WEST","Western Indonesia Time":"WIB","Yakutsk Standard Time":"YAKT","Yakutsk Summer Time":"YAKST","Yekaterinburg Standard Time":"YEKT","Yekaterinburg Summer Time":"YEKST","Yukon Time":"YT"};class T{}const e=a=>!!a&&"object"==typeof a&&"zone_name"in a&&"gmt_offset"in a,i=(a,T)=>{const e=new Intl.DateTimeFormat("en-US",{timeZone:T??void 0,timeZoneName:"long"}).formatToParts(a);return e.find(a=>"timeZoneName"===a.type)?.value.replace(/^GMT[+-].+$/,"")??""};const m=new class extends T{z(T,m){const r=e(m.timeZone)?m.timeZone.zone_name:m.timeZone;return((T,e)=>a[i(T,e)]||"")(T.getTime(),r)}zz(a,T){const m=e(T.timeZone)?T.timeZone.zone_name:T.timeZone;return i(a.getTime(),m)}};export{m as formatter};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "date-and-time",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"description": "The simplest, most intuitive date and time library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -89,23 +89,22 @@
|
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@eslint/js": "^10.0.1",
|
|
91
91
|
"@rollup/plugin-alias": "^6.0.0",
|
|
92
|
-
"@rollup/plugin-terser": "^0.
|
|
93
|
-
"@stylistic/eslint-plugin": "^5.
|
|
94
|
-
"@types/node": "^25.
|
|
95
|
-
"@vitest/coverage-v8": "^4.
|
|
96
|
-
"eslint": "^10.0
|
|
92
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
93
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
94
|
+
"@types/node": "^25.5.0",
|
|
95
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
96
|
+
"eslint": "^10.1.0",
|
|
97
97
|
"glob": "^13.0.6",
|
|
98
98
|
"prettier": "^3.8.1",
|
|
99
|
-
"rollup": "^4.
|
|
100
|
-
"rollup-plugin-dts": "^6.
|
|
99
|
+
"rollup": "^4.60.0",
|
|
100
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
101
101
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
102
102
|
"tsx": "^4.21.0",
|
|
103
|
-
"typescript-eslint": "^8.
|
|
103
|
+
"typescript-eslint": "^8.57.2",
|
|
104
104
|
"vitepress": "^1.6.4",
|
|
105
|
-
"vitest": "^4.
|
|
105
|
+
"vitest": "^4.1.2"
|
|
106
106
|
},
|
|
107
107
|
"overrides": {
|
|
108
|
-
"esbuild": "^0.25.0"
|
|
109
|
-
"minimatch": "^10.2.2"
|
|
108
|
+
"esbuild": "^0.25.0"
|
|
110
109
|
}
|
|
111
110
|
}
|