@coreify/tarikh 1.0.1 → 1.1.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/LICENSE +21 -21
- package/README.md +291 -83
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +97 -10
- package/dist/index.d.ts +97 -10
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.d.cts +31 -1
- package/dist/react.d.ts +31 -1
- package/dist/react.js +1 -1
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],u=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],i=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],d=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],c=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],g=[31,31,31,31,31,30,30,30,30,30,30,30],h={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},f={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function m(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function y(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var D={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function p(t){const e=t.trim(),o=e.toLowerCase(),a=D[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<s.length;t++)if(s[t]===e)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;return-1}function b(t,e,n,r=0,o=0,a=0,s=0){const u=new Date(t,e,n,r,o,a,s);return u.getFullYear()!==t||u.getMonth()!==e||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==s?null:u}function M(t){return function(t){const e=t.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?b(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),s=Number(e[5]??0),u=Number(e[6]??0),i=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),l=e[8];if(void 0===l)return b(n,r-1,o,a,s,u,i);const d=l.match(/^([+-])(\d{2}):?(\d{2})$/),c=d?Number(d[2]):null,g=d?Number(d[3]):null,h="Z"===l?0:d&&null!==c&&null!==g&&c<=23&&g<=59?("+"===d[1]?1:-1)*(60*c+g):null;if(null===h)return null;const f=Date.UTC(n,r-1,o,a,s,u,i)-6e4*h,m=new Date(f),y=new Date(f+6e4*h);return y.getUTCFullYear()!==n||y.getUTCMonth()!==r-1||y.getUTCDate()!==o||y.getUTCHours()!==a||y.getUTCMinutes()!==s||y.getUTCSeconds()!==u||y.getUTCMilliseconds()!==i?null:m}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=p(r);if(-1===a)return null;let s=Number(o);return 2===o.length&&(s+=s>=50?1900:2e3),b(s,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=p(n);if(-1===a)return null;let s=Number(o);return 2===o.length&&(s+=s>=50?1900:2e3),b(s,a,r)}(t)}function w(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return new Date(e)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`Invalid date input: ${String(t)}`);return e}const e=M(y(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return e}function N(t,e){const n=w(t);return n.setDate(n.getDate()+e),n}function S(t,e){return new Date(t,e+1,0).getDate()}function $(t,e){const n=w(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),s=(o%12+12)%12,u=Math.min(n.getDate(),S(a,s));return n.setFullYear(a,s,u),n}function x(t,e){const n=w(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),S(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),n}function T(t){const e=[...g];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function Y(t,e){const n=e?.locale??"en-BD",r=w(t),o=r.getFullYear(),a=r.getMonth(),s=r.getDate(),u=new Date(o,3,14),i=a<3||3===a&&s<14,l=i?o-594:o-593,g=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(i?new Date(o-1,3,14):u,r)+1,h=T(l);let f=g,y=0;for(let t=0;t<h.length;t++){const e=h[t];if(f<=e){y=t;break}f-=e}const D=y+1;return"bn-BD"===n?{day:m(f),month:d[y],monthIndex:D,year:m(l)}:{day:f,month:c[y],monthIndex:D,year:l}}function v(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=T(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const s=new Date(o);return s.setDate(s.getDate()+a),s}function A(t){const e=m(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function E(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return A(t)}}(t,e?.variant):A(t)}function H(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function B(t,e,n){const r=H(t,n);return"bn-BD"===e?m(r):r}function F(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}`)}function _(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}var I={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},L={"বৈশাখ":1,"জৈষ্ঠ":2,"জ্যৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ়":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12};var k=1e3,j=36e5,O=24*j,C=[{threshold:7*O,singular:"week",plural:"weeks"},{threshold:O,singular:"day",plural:"days"},{threshold:j,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:k,singular:"second",plural:"seconds"}];function G(t,e){return new Date(t,e+1,0).getDate()}function U(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),G(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function R(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,s=Math.min(t.getDate(),G(o,a));return new Date(o,a,s,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function J(t,e,n,r,o){const a="bn-BD"===o,s=a?m(t):String(t),u=1===t?e:n;return a?r?`${s} ${u} আগে`:`${s} ${u} পরে`:r?`${s} ${u} ago`:`in ${s} ${u}`}function K(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}exports.BANGLA_CALENDAR_MONTHS=d,exports.BANGLA_CALENDAR_MONTHS_EN=c,exports.BANGLA_CALENDAR_MONTH_DAYS=g,exports.BANGLA_DIGITS=e,exports.BANGLA_MONTHS_FULL=s,exports.BANGLA_MONTHS_SHORT=u,exports.BANGLA_WEEKDAYS_FULL=i,exports.BANGLA_WEEKDAYS_SHORT=l,exports.BOISHAKH_START_DAY=14,exports.BOISHAKH_START_MONTH=3,exports.ENGLISH_DIGITS=t,exports.ENGLISH_MONTHS_FULL=n,exports.ENGLISH_MONTHS_SHORT=r,exports.ENGLISH_WEEKDAYS_FULL=o,exports.ENGLISH_WEEKDAYS_SHORT=a,exports.RELATIVE_TIME_BN=f,exports.RELATIVE_TIME_EN=h,exports.addDays=N,exports.addMonths=$,exports.addYears=x,exports.endOfDay=function(t){const e=w(t);return e.setHours(23,59,59,999),e},exports.endOfMonth=function(t){const e=w(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),e},exports.endOfYear=function(t){const e=w(t);return e.setMonth(11,31),e.setHours(23,59,59,999),e},exports.format=function(t,e){if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError("format() expects an options object");if("pattern"in e&&void 0!==e.pattern){if("mode"in e&&void 0!==e.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const d="locale"in e&&void 0!==e.locale?e.locale:"en-BD";return function(t,e,d="en-BD"){const c=w(t),g="bn-BD"===d,h=c.getDate(),f=c.getMonth(),m=c.getFullYear(),y=g?s:n,D=g?u:r,p=g?i:o,b=g?l:a,M=c.getHours(),N=M%12||12,S={dddd:p[c.getDay()],ddd:b[c.getDay()],MMMM:y[f],MMM:D[f],MM:B(f+1,d,"2-digit"),M:B(f+1,d,"numeric"),DD:B(h,d,"2-digit"),D:B(h,d,"numeric"),HH:B(M,d,"2-digit"),H:B(M,d,"numeric"),hh:B(N,d,"2-digit"),h:B(N,d,"numeric"),mm:B(c.getMinutes(),d,"2-digit"),m:B(c.getMinutes(),d,"numeric"),ss:B(c.getSeconds(),d,"2-digit"),s:B(c.getSeconds(),d,"numeric"),A:_(M,d,!1),a:_(M,d,!0),YYYY:B(m,d,"numeric"),YY:B(Number(String(m).slice(-2)),d,"2-digit")},$=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,x=t=>t.replace($,t=>S[t]);let T="",Y=0;for(;Y<e.length;){const t=e.indexOf("[",Y);if(-1===t){T+=x(e.slice(Y));break}T+=x(e.slice(Y,t));const n=e.indexOf("]",t+1);if(-1===n){T+=e.slice(t);break}T+=e.slice(t+1,n),Y=n+1}return T}(t,e.pattern,d)}if(!("mode"in e)||void 0===e.mode)throw new TypeError("format() expects `mode` or `pattern`");const c=e.mode;switch(c){case"standard":return function(t,e){const d=w(t),c=e?.locale??"en-BD",g=e?.month??"short",h=e?.year??"numeric",f=e?.day??"numeric",y=e?.weekday,D=e?.hour,p=e?.minute,b=e?.second,M=void 0!==D||void 0!==p||void 0!==b,N="bn-BD"===c;F(g,["short","long"],"month format for standard mode"),F(h,["numeric","2-digit"],"year format for standard mode"),F(f,["numeric","2-digit"],"day format for standard mode"),void 0!==y&&F(y,["short","long"],"weekday format for standard mode"),void 0!==D&&F(D,["numeric","2-digit"],"hour format for standard mode"),void 0!==p&&F(p,["numeric","2-digit"],"minute format for standard mode"),void 0!==b&&F(b,["numeric","2-digit"],"second format for standard mode");const S=d.getDate(),$=d.getMonth(),x=d.getFullYear(),T=`${"2-digit"===f?String(S).padStart(2,"0"):String(S)} ${(N?"short"===g?u:s:"short"===g?r:n)[$]} ${"2-digit"===h?String(x).slice(-2):String(x)}`,Y=void 0!==y?`${(N?"short"===y?l:i:"short"===y?a:o)[d.getDay()]}, `:"";let v="";if(M){const t=e?.hour12??!1,n=d.getHours(),r=p??(void 0!==b?"2-digit":void 0);v=`${H(t?n%12||12:n,D??"numeric")}${void 0!==r?`:${H(d.getMinutes(),r)}`:""}${void 0!==b?`:${H(d.getSeconds(),b)}`:""}${t?` ${_(n,c,!1)}`:""}`}const A=`${Y}${T}${v?`, ${v}`:""}`;return N?m(A):A}(t,e);case"bangla":return function(t,e){const n=e?.locale??"en-BD",r=e?.format??"ordinal",o=e?.variant,a=Y(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${E(a.day,e)} ${d[t]} ${m(a.year)}`}return`${a.day} ${a.month} ${a.year}`}(t,e);case"hybrid":return function(t,e){const o=w(t),a=e?.digits??"en",i=e?.month??"bn",l=e?.year??"en",d=e?.day??a,c=e?.monthFormat??"long";F(a,["en","bn"],"digits language for hybrid mode"),F(i,["en","bn"],"month language for hybrid mode"),F(l,["en","bn"],"year language for hybrid mode"),F(d,["en","bn"],"day language for hybrid mode"),F(c,["short","long"],"month format for hybrid mode");const g=o.getDate(),h=o.getMonth(),f=o.getFullYear(),y="bn"===i?"short"===c?u:s:"short"===c?r:n,D="bn"===d?m(g):String(g),p=y[h],b="bn"===l?m(f):String(f);return`${D} ${p} ${b}`}(t,e);default:throw new TypeError(`Invalid format mode: ${String(c)}`)}},exports.formatBanglaCalendarDay=E,exports.fromBanglaCalendar=v,exports.fromNow=function(t,e){const n=w(t),r=e?.locale??"en-BD",o=e?.numeric??"always",a="bn-BD"===r?f:h,s=Date.now()-n.getTime(),u=Math.abs(s),i=s>0,l=new Date,d=n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),c=i?l:n,g=i?n:l;if(u<k)return a.justNow;if("auto"===o&&d)return function(t){return"bn-BD"===t?"আজ":"today"}(r);const m=U(c,g);if(m>=1){if("auto"===o&&1===m){const t=K("year",i,r);if(null!==t)return t}return J(m,a.year,a.years,i,r)}const y=R(c,g);if(y>=1){if("auto"===o&&1===y){const t=K("month",i,r);if(null!==t)return t}return J(y,a.month,a.months,i,r)}for(const t of C)if(u>=t.threshold){const e=Math.floor(u/t.threshold);if("auto"===o&&1===e&&("day"===t.singular||"week"===t.singular)){const e=K(t.singular,i,r);if(null!==e)return e}return J(e,a[t.singular],a[t.plural],i,r)}return a.justNow},exports.getBanglaMonth=function(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?u[n]:s[n]},exports.isToday=function(t){const e=w(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isTomorrow=function(t){const e=w(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isYesterday=function(t){const e=w(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.parseDate=function(t,e){if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getTime());if("number"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?null:e}const n=y(t).trim();return"bangla"===e?.calendar?function(t){const e=t.match(/^(\S+),?\s+(\S+),?\s+(\d{4})$/);if(!e)return null;const n=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=31?r:null}(e[1].replace(/,$/,""));if(null===n)return null;const r=function(t){const e=t.toLowerCase();for(let e=0;e<d.length;e++)if(d[e]===t)return e+1;const n=L[t];if(void 0!==n)return n;for(let t=0;t<c.length;t++)if(c[t].toLowerCase()===e)return t+1;const r=I[e];return void 0!==r?r:-1}(e[2].replace(/,$/,""));if(-1===r)return null;const o=Number(e[3]);try{return v(n,r,o)}catch{return null}}(n):M(n)},exports.startOfDay=function(t){const e=w(t);return e.setHours(0,0,0,0),e},exports.startOfMonth=function(t){const e=w(t);return e.setDate(1),e.setHours(0,0,0,0),e},exports.startOfYear=function(t){const e=w(t);return e.setMonth(0,1),e.setHours(0,0,0,0),e},exports.subDays=function(t,e){return N(t,-e)},exports.subMonths=function(t,e){return $(t,-e)},exports.subYears=function(t,e){return x(t,-e)},exports.toBanglaCalendar=Y,exports.toBanglaDigits=m,exports.toDate=w,exports.toEnglishDigits=y;
|
|
1
|
+
"use strict";var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],s=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],u=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],d=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],l=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],c=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],m=[31,31,31,31,31,30,30,30,30,30,30,30],h={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},g={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function f(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function y(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var p={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11};function b(t){const e=t.trim(),o=e.toLowerCase(),a=p[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<i.length;t++)if(i[t]===e)return t;for(let t=0;t<s.length;t++)if(s[t]===e)return t;return-1}function D(t){return Number.isFinite(t)&&Math.abs(t)<=864e13}function w(t,e,n,r=0,o=0,a=0,i=0){const s=new Date(0);return s.setUTCFullYear(t,e,n),s.setUTCHours(r,o,a,i),s.getUTCFullYear()!==t||s.getUTCMonth()!==e||s.getUTCDate()!==n||s.getUTCHours()!==r||s.getUTCMinutes()!==o||s.getUTCSeconds()!==a||s.getUTCMilliseconds()!==i?null:s}function $(t,e,n,r=0,o=0,a=0,i=0){return function(t,e,n,r=0,o=0,a=0,i=0){const s=new Date(0);return s.setFullYear(t,e,n),s.setHours(r,o,a,i),s.getFullYear()!==t||s.getMonth()!==e||s.getDate()!==n||s.getHours()!==r||s.getMinutes()!==o||s.getSeconds()!==a||s.getMilliseconds()!==i?null:s}(t,e,n,r,o,a,i)??w(t,e,n,r,o,a,i)}function M(t){if(!/^[+-]?\d+$/.test(t))return null;const e=Number(t);return Number.isInteger(e)?e:null}function S(t){return function(t){const e=t.trim().match(/^([+-]\d{6}|\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?$(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),i=Number(e[5]??0),s=Number(e[6]??0),u=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),d=e[8];if(void 0===d)return $(n,r-1,o,a,i,s,u);const l=d.match(/^([+-])(\d{2}):?(\d{2})$/),c=l?Number(l[2]):null,m=l?Number(l[3]):null,h="Z"===d?0:l&&null!==c&&null!==m&&c<=23&&m<=59?("+"===l[1]?1:-1)*(60*c+m):null;if(null===h)return null;const g=w(n,r-1,o,a,i,s,u);if(!g)return null;const f=g.getTime()-6e4*h;if(!D(f))return null;const y=new Date(f),p=new Date(f+6e4*h);return p.getUTCFullYear()!==n||p.getUTCMonth()!==r-1||p.getUTCDate()!==o||p.getUTCHours()!==a||p.getUTCMinutes()!==i||p.getUTCSeconds()!==s||p.getUTCMilliseconds()!==u?null:y}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4}|\d{2})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=b(r);if(-1===a)return null;const i=M(o);if(null===i)return null;let s=i;return o.startsWith("+")||o.startsWith("-")||2!==o.length||(s+=s>=50?1900:2e3),$(s,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4}|\d{2})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=b(n);if(-1===a)return null;const i=M(o);if(null===i)return null;let s=i;return o.startsWith("+")||o.startsWith("-")||2!==o.length||(s+=s>=50?1900:2e3),$(s,a,r)}(t)}function v(t,e,n){if(!D(t.getTime())){throw new RangeError(`${void 0===n?"Date input":`${n} output`} is outside the supported range: ${String(e)}`)}return t}function N(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return v(new Date(e),t)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime())){if(!D(t))throw new RangeError(`Date input is outside the supported range: ${String(t)}`);throw new Error(`Invalid date input: ${String(t)}`)}return v(e,t)}const e=S(y(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return v(e,t)}function T(t,e){const n=N(t);return n.setDate(n.getDate()+e),v(n,t,"addDays()")}function _(t,e){return new Date(t,e+1,0).getDate()}function x(t,e){const n=N(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),i=(o%12+12)%12,s=Math.min(n.getDate(),_(a,i));return n.setFullYear(a,i,s),v(n,t,"addMonths()")}function j(t,e){const n=N(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),_(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),v(n,t,"addYears()")}function Y(t){const e=[...m];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function I(t,e){const n=e?.locale??"en-BD",r=N(t),o=r.getFullYear(),a=r.getMonth(),i=r.getDate(),s=new Date(o,3,14),u=a<3||3===a&&i<14,d=u?o-594:o-593,m=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(u?new Date(o-1,3,14):s,r)+1,h=Y(d);let g=m,y=0;for(let t=0;t<h.length;t++){const e=h[t];if(g<=e){y=t;break}g-=e}const p=y+1;return"bn-BD"===n?{day:f(g),month:l[y],monthIndex:p,year:f(d)}:{day:g,month:c[y],monthIndex:p,year:d}}function B(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=Y(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const i=new Date(o);return i.setDate(i.getDate()+a),v(i,{day:t,monthIndex:e,year:n},"fromBanglaCalendar()")}var H=["Asia/Dhaka","UTC"],A={locale:"en-BD",mode:"standard",month:void 0,timeZone:"Asia/Dhaka",hijriSystem:"islamic-umalqura"},E={...A};function F(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}. Supported values: ${e.join(", ")}`)}function k(t,e){return null===e?A[t]:void 0!==e?e:void 0}function C(){return{...E}}function L(t,e){const n=t.find(t=>t.type===e);if(void 0===n)throw new Error(`Missing ${e} part while formatting Hijri date.`);return n.value}function O(t,e){const n=C(),r=e?.locale??"en-BD",o=e?.timeZone??n.timeZone,a=e?.hijriSystem??n.hijriSystem;!function(t){if(!H.includes(t))throw new RangeError(`Unsupported Hijri time zone: ${t}. Supported values: ${H.join(", ")}`)}(o),function(t){if(!["islamic-umalqura","islamic-civil"].includes(t))throw new RangeError(`Unsupported Hijri calendar system: ${t}. Supported values: islamic-umalqura, islamic-civil`)}(a);const i=function(t,e,n,r){const o=function(t,e){return`${t}-u-ca-${e}`}(e,r),a=new Intl.DateTimeFormat(o,{day:"numeric",month:"numeric",year:"numeric",timeZone:n}).formatToParts(t),i=new Intl.DateTimeFormat(o,{day:"numeric",month:"long",year:"numeric",timeZone:n}).formatToParts(t);return{day:L(a,"day"),month:L(i,"month"),monthIndex:Number(y(L(a,"month"))),year:L(a,"year")}}(N(t),r,o,a);return"bn-BD"===r?{day:f(i.day),month:i.month,monthIndex:i.monthIndex,year:f(i.year)}:{day:Number(y(i.day)),month:i.month,monthIndex:i.monthIndex,year:Number(y(i.year))}}function U(t){const e=f(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function Z(t){const e=t%100;if(e>=11&&e<=13)return`${t}th`;switch(t%10){case 1:return`${t}st`;case 2:return`${t}nd`;case 3:return`${t}rd`;default:return`${t}th`}}function R(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return U(t)}}(t,e?.variant):U(t)}function G(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function W(t,e,n){const r=G(t,n);return"bn-BD"===e?f(r):r}function J(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}`)}function K(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}function q(t,e){const n=N(t),r=`${o=n.getFullYear(),o>=0&&o<=9999?String(o).padStart(4,"0"):`${o>=0?"+":"-"}${String(Math.abs(o)).padStart(6,"0")}`}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")} ${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}:${String(n.getSeconds()).padStart(2,"0")}`;var o;return"bn-BD"===e?f(r):r}var z={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},P={"বৈশাখ":1,"জ্যৈষ্ঠ":2,"জৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12},V=/^([+-]\d{6}|\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/,Q=/^([+-]\d{6}|\d{4})([-/.])(\d{2})\2(\d{2})$/,X=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/,tt=/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4}|\d{2})$/i,et=/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4})$/i,nt=/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4}|\d{2})$/i,rt=/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4})$/i;function ot(t){const e=t.toLowerCase();for(let e=0;e<l.length;e+=1)if(l[e]===t)return e+1;const n=P[t];if(void 0!==n)return n;for(let t=0;t<c.length;t+=1)if(c[t].toLowerCase()===e)return t+1;const r=z[e];return void 0!==r?r:-1}function at(t){const e=t.trim(),o=e.toLowerCase();for(let t=0;t<n.length;t+=1)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t+=1)if(r[t].toLowerCase()===o)return t;for(let t=0;t<i.length;t+=1)if(i[t]===e)return t;for(let t=0;t<s.length;t+=1)if(s[t]===e)return t;return-1}function it(t,e,n,r,o,a){return{success:!0,input:t,normalizedInput:e,calendar:n,strict:r,format:o,date:a}}function st(t,e,n,r,o,a){return{success:!1,input:t,normalizedInput:e,calendar:n,strict:r,reason:o,message:a,date:null}}function ut(t){if(V.test(t))return"ymd";if(X.test(t))return"iso_datetime";const e=t.match(tt);if(e&&-1!==b(e[2].replace(/,$/,"")))return"day_month_year";const n=t.match(nt);return n&&-1!==b(n[1].replace(/,$/,""))?"month_day_year":null}function dt(t,e,n){const r=n?function(t){if(Q.test(t))return"ymd";if(X.test(t))return"iso_datetime";const e=t.match(et);if(e&&-1!==at(e[2].replace(/,$/,"")))return"day_month_year";const n=t.match(rt);return n&&-1!==at(n[1].replace(/,$/,""))?"month_day_year":null}(e):ut(e);if(null===r){if(n){if(null!==ut(e)&&null!==S(e))return st(t,e,"gregorian",!0,"strict_mismatch","Input matches a supported loose Gregorian format but fails strict parsing.")}return st(t,e,"gregorian",n,"invalid_string","Input does not match a supported Gregorian date format.")}const o=S(e);return null===o?st(t,e,"gregorian",n,"invalid_string","Input matches a Gregorian date shape but is not a valid calendar date."):it(t,e,"gregorian",n,r,o)}function lt(t,e,n){const r=e.match(/^(\S+),?\s+(\S+),?\s+(\d+)$/);if(!r)return st(t,e,"bangla",n,"invalid_string","Input does not match a supported Bangla calendar date format.");const o=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=t.match(/^(\d{1,2})(?:st|nd|rd|th)$/i);if(r)return Number(r[1]);const o=Number(t);return Number.isInteger(o)&&o>=1&&o<=31?o:null}(r[1].replace(/,$/,""));if(null===o)return st(t,e,"bangla",n,"invalid_string","Bangla calendar day is invalid.");const a=r[2].replace(/,$/,""),i=n?function(t){for(let e=0;e<l.length;e+=1)if(l[e]===t)return e+1;const e=t.toLowerCase();for(let t=0;t<c.length;t+=1)if(c[t].toLowerCase()===e)return t+1;return-1}(a):ot(a);if(-1===i)return n?-1!==ot(a)?st(t,e,"bangla",!0,"strict_mismatch","Input uses a legacy Bangla month alias that is rejected in strict mode."):st(t,e,"bangla",!0,"invalid_string","Bangla calendar month is invalid."):st(t,e,"bangla",!1,"invalid_string","Bangla calendar month is invalid.");const s=Number(r[3]);try{return it(t,e,"bangla",n,"bangla_calendar",B(o,i,s))}catch(r){return st(t,e,"bangla",n,"invalid_bangla_calendar_date",r instanceof Error?r.message:"Bangla calendar date is invalid.")}}function ct(t,e){const n=e?.calendar??"gregorian",r=e?.strict??!1;if(t instanceof Date)return Number.isNaN(t.getTime())?st(t,null,n,r,"invalid_date_object","Date object is invalid."):it(t,null,n,r,"date_object",new Date(t.getTime()));if("number"==typeof t){if(!Number.isFinite(t))return st(t,t,n,r,"invalid_timestamp","Timestamp is invalid.");const e=new Date(t);if(Number.isNaN(e.getTime())){const e=Math.abs(t)>864e13;return st(t,t,n,r,e?"out_of_range":"invalid_timestamp",e?"Timestamp is outside the supported Date range.":"Timestamp is invalid.")}return it(t,t,n,r,"timestamp",e)}const o=y(t).trim();return 0===o.length?st(t,o,n,r,"invalid_string","Input is empty."):"bangla"===n?lt(t,o,r):dt(t,o,r)}var mt=1e3,ht=36e5,gt=24*ht,ft={second:"s",seconds:"s",minute:"m",minutes:"m",hour:"h",hours:"h",day:"d",days:"d",week:"wk",weeks:"wk",month:"mo",months:"mo",year:"y",years:"y",ago:"ago",in:"in",justNow:"now"},yt={second:"সে.",seconds:"সে.",minute:"মি.",minutes:"মি.",hour:"ঘ.",hours:"ঘ.",day:"দিন",days:"দিন",week:"সপ্তা.",weeks:"সপ্তা.",month:"মাস",months:"মাস",year:"বছ.",years:"বছ.",ago:"আগে",in:"",justNow:"এখন"},pt={justNow:mt,minute:6e4,hour:ht,day:gt,week:7*gt,month:30*gt,year:365*gt};function bt(t,e){return new Date(t,e+1,0).getDate()}function Dt(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),bt(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function wt(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,i=Math.min(t.getDate(),bt(o,a));return new Date(o,a,i,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function $t(t,e){if(!Number.isFinite(t)||t<0)throw new RangeError(`Invalid relative time threshold for ${e}: ${t}`)}function Mt(t,e,n,r,o,a){const i="bn-BD"===o,s=i?f(t):String(t),u=1===t?e:n,d="short"===a&&"en-BD"===o?`${s}${u}`:`${s} ${u}`;return i?r?`${d} আগে`:`${d} পরে`:r?`${d} ago`:`in ${d}`}function St(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}exports.BANGLA_CALENDAR_MONTHS=l,exports.BANGLA_CALENDAR_MONTHS_EN=c,exports.BANGLA_CALENDAR_MONTH_DAYS=m,exports.BANGLA_DIGITS=e,exports.BANGLA_MONTHS_FULL=i,exports.BANGLA_MONTHS_SHORT=s,exports.BANGLA_WEEKDAYS_FULL=u,exports.BANGLA_WEEKDAYS_SHORT=d,exports.BOISHAKH_START_DAY=14,exports.BOISHAKH_START_MONTH=3,exports.ENGLISH_DIGITS=t,exports.ENGLISH_MONTHS_FULL=n,exports.ENGLISH_MONTHS_SHORT=r,exports.ENGLISH_WEEKDAYS_FULL=o,exports.ENGLISH_WEEKDAYS_SHORT=a,exports.HIJRI_TIME_ZONES=H,exports.RELATIVE_TIME_BN=g,exports.RELATIVE_TIME_EN=h,exports.addDays=T,exports.addMonths=x,exports.addYears=j,exports.endOfDay=function(t){const e=N(t);return e.setHours(23,59,59,999),v(e,t,"endOfDay()")},exports.endOfMonth=function(t){const e=N(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),v(e,t,"endOfMonth()")},exports.endOfYear=function(t){const e=N(t);return e.setMonth(11,31),e.setHours(23,59,59,999),v(e,t,"endOfYear()")},exports.format=function(t,e){if(void 0!==e&&(null===e||"object"!=typeof e||Array.isArray(e)))throw new TypeError("format() expects an options object");const c=C();if(e&&"pattern"in e&&void 0!==e.pattern){if("mode"in e&&void 0!==e.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const l=e.locale??c.locale;return function(t,e,l="en-BD"){const c=N(t),m="bn-BD"===l,h=c.getDate(),g=c.getMonth(),f=c.getFullYear(),y=m?i:n,p=m?s:r,b=m?u:o,D=m?d:a,w=c.getHours(),$=w%12||12,M={dddd:b[c.getDay()],ddd:D[c.getDay()],MMMM:y[g],MMM:p[g],MM:W(g+1,l,"2-digit"),M:W(g+1,l,"numeric"),DD:W(h,l,"2-digit"),D:W(h,l,"numeric"),HH:W(w,l,"2-digit"),H:W(w,l,"numeric"),hh:W($,l,"2-digit"),h:W($,l,"numeric"),mm:W(c.getMinutes(),l,"2-digit"),m:W(c.getMinutes(),l,"numeric"),ss:W(c.getSeconds(),l,"2-digit"),s:W(c.getSeconds(),l,"numeric"),A:K(w,l,!1),a:K(w,l,!0),YYYY:W(f,l,"numeric"),YY:W(Number(String(f).slice(-2)),l,"2-digit")},S=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,v=t=>t.replace(S,t=>M[t]);let T="",_=0;for(;_<e.length;){const t=e.indexOf("[",_);if(-1===t){T+=v(e.slice(_));break}T+=v(e.slice(_,t));const n=e.indexOf("]",t+1);if(-1===n){T+=e.slice(t);break}T+=e.slice(t+1,n),_=n+1}return T}(t,e.pattern,l)}const m=function(t,e){if(void 0===t)return e;if("mode"in t&&void 0!==t.mode)return t.mode;const n=t;return"digits"in n||"monthFormat"in n||"en"===n.month||"bn"===n.month||"en"===n.year||"bn"===n.year||"en"===n.day||"bn"===n.day?"hybrid":"timeZone"in n||"hijriSystem"in n?"hijri":"format"in n||"variant"in n?"bangla":"weekday"in n||"hour"in n||"minute"in n||"second"in n||"hour12"in n||"preset"in n||"short"===n.month||"long"===n.month||"numeric"===n.year||"2-digit"===n.year||"numeric"===n.day||"2-digit"===n.day?"standard":e}(e,c.mode);switch(m){case"standard":return function(t,e){const l=C(),c=e?.locale??l.locale;if("isoLike"===e?.preset)return q(t,c);const m=function(t){return"dateTime"===t?.preset?{hour:"2-digit",minute:"2-digit",...t}:t??{}}(e),h=N(t),g=m.month??l.month??("bn-BD"===c?"long":"short"),y=m.year??"numeric",p=m.day??"numeric",b=m.weekday,D=m.hour,w=m.minute,$=m.second,M=void 0!==D||void 0!==w||void 0!==$,S="bn-BD"===c;J(g,["short","long"],"month format for standard mode"),J(y,["numeric","2-digit"],"year format for standard mode"),J(p,["numeric","2-digit"],"day format for standard mode"),void 0!==b&&J(b,["short","long"],"weekday format for standard mode"),void 0!==D&&J(D,["numeric","2-digit"],"hour format for standard mode"),void 0!==w&&J(w,["numeric","2-digit"],"minute format for standard mode"),void 0!==$&&J($,["numeric","2-digit"],"second format for standard mode");const v=h.getDate(),T=h.getMonth(),_=h.getFullYear(),x=S?" খ্রিস্টাব্দ":"",j=`${"2-digit"===p?String(v).padStart(2,"0"):S?U(v):Z(v)} ${(S?"short"===g?s:i:"short"===g?r:n)[T]} ${"2-digit"===y?String(_).slice(-2):String(_)}${x}`,Y=void 0!==b?`${(S?"short"===b?d:u:"short"===b?a:o)[h.getDay()]}, `:"";let I="";if(M){const t=m.hour12??!1,e=h.getHours(),n=w??(void 0!==$?"2-digit":void 0);I=`${G(t?e%12||12:e,D??"numeric")}${void 0!==n?`:${G(h.getMinutes(),n)}`:""}${void 0!==$?`:${G(h.getSeconds(),$)}`:""}${t?` ${K(e,c,!1)}`:""}`}const B=`${Y}${j}${I?`, ${I}`:""}`;return S?f(B):B}(t,e);case"bangla":return function(t,e){const n=e?.locale??C().locale,r=e?.format??"ordinal",o=e?.variant,a=I(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${R(a.day,e)} ${l[t]} ${f(a.year)} বঙ্গাব্দ`}return`${Z(a.day)} ${a.month} ${a.year}`}(t,e);case"hijri":return function(t,e){const n=e?.locale??C().locale;if("bn-BD"===n){const n=O(t,{locale:"bn-BD",...void 0!==e?.timeZone&&{timeZone:e.timeZone},...void 0!==e?.hijriSystem&&{hijriSystem:e.hijriSystem}}),r=f(n.year);return`${function(t){const e=f(t);return 1===t?`${e}লা`:2===t?`${e}রা`:`${e}ই`}(Number(y(n.day)))} ${n.month} ${r} হিজরি`}const r=O(t,{locale:"en-BD",...void 0!==e?.timeZone&&{timeZone:e.timeZone},...void 0!==e?.hijriSystem&&{hijriSystem:e.hijriSystem}});return`${Z(r.day)} ${r.month} ${r.year} AH`}(t,e);case"hybrid":return function(t,e){const o=N(t),a=e?.digits??"en",u=e?.month??"bn",d=e?.year??"en",l=e?.day??a,c=e?.monthFormat??"long";J(a,["en","bn"],"digits language for hybrid mode"),J(u,["en","bn"],"month language for hybrid mode"),J(d,["en","bn"],"year language for hybrid mode"),J(l,["en","bn"],"day language for hybrid mode"),J(c,["short","long"],"month format for hybrid mode");const m=o.getDate(),h=o.getMonth(),g=o.getFullYear(),y="bn"===u?"short"===c?s:i:"short"===c?r:n,p="bn"===l?f(m):String(m),b=y[h],D="bn"===d?f(g):String(g);return`${p} ${b} ${D}`}(t,e);default:throw new TypeError(`Invalid format mode: ${String(m)}`)}},exports.formatBanglaCalendarDay=R,exports.fromBanglaCalendar=B,exports.fromNow=function(t,e){const n=C(),r=N(t),o=e?.locale??n.locale,a=e?.numeric??"always",i=e?.style??"long",s=function(t){const e={...pt,...t};$t(e.justNow,"justNow"),$t(e.minute,"minute"),$t(e.hour,"hour"),$t(e.day,"day"),$t(e.week,"week"),$t(e.month,"month"),$t(e.year,"year");const n=[e.justNow,e.minute,e.hour,e.day,e.week,e.month,e.year];for(let t=1;t<n.length;t+=1)if(n[t]<n[t-1])throw new RangeError("Relative time thresholds must be non-decreasing from justNow to year");return e}(e?.threshold),u=void 0===e?.baseDate?new Date:N(e.baseDate),d=function(t,e){return"short"===e?"bn-BD"===t?yt:ft:"bn-BD"===t?g:h}(o,i),l=u.getTime()-r.getTime(),c=Math.abs(l),m=l>0,f=m?u:r,y=m?r:u;if(c<s.justNow)return d.justNow;if("auto"===a&&(b=u,(p=r).getFullYear()===b.getFullYear()&&p.getMonth()===b.getMonth()&&p.getDate()===b.getDate()))return function(t){return"bn-BD"===t?"আজ":"today"}(o);var p,b;const D=Dt(f,y);if(D>=1&&c>=s.year){if("auto"===a&&1===D){const t=St("year",m,o);if(null!==t)return t}return Mt(D,d.year,d.years,m,o,i)}const w=wt(f,y);if(w>=1&&c>=s.month){if("auto"===a&&1===w){const t=St("month",m,o);if(null!==t)return t}return Mt(w,d.month,d.months,m,o,i)}const $=[{threshold:s.week,singular:"week",plural:"weeks"},{threshold:s.day,singular:"day",plural:"days"},{threshold:s.hour,singular:"hour",plural:"hours"},{threshold:s.minute,singular:"minute",plural:"minutes"},{threshold:mt,singular:"second",plural:"seconds"}];for(const t of $)if(c>=t.threshold){const e=Math.floor(c/t.threshold);if("auto"===a&&1===e&&("day"===t.singular||"week"===t.singular)){const e=St(t.singular,m,o);if(null!==e)return e}return Mt(e,d[t.singular],d[t.plural],m,o,i)}return d.justNow},exports.getBanglaMonth=function(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?s[n]:i[n]},exports.getDefaults=C,exports.isToday=function(t){const e=N(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isTomorrow=function(t){const e=N(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.isYesterday=function(t){const e=N(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()},exports.parseDate=function(t,e){const n=ct(t,e);return n.success?n.date:null},exports.parseDateDetailed=ct,exports.setDefaults=function(t={}){const e={...E};if("locale"in t){const n=k("locale",t.locale);void 0!==n&&(F(n,["en-BD","bn-BD"],"default locale"),e.locale=n)}if("mode"in t){const n=k("mode",t.mode);void 0!==n&&(F(n,["standard","bangla","hijri","hybrid"],"default mode"),e.mode=n)}if("month"in t){const n=k("month",t.month);void 0===n?e.month=void 0:(F(n,["short","long"],"default month format"),e.month=n)}if("timeZone"in t){const n=k("timeZone",t.timeZone);void 0!==n&&(F(n,H,"default Hijri time zone"),e.timeZone=n)}if("hijriSystem"in t){const n=k("hijriSystem",t.hijriSystem);void 0!==n&&(F(n,["islamic-umalqura","islamic-civil"],"default Hijri calendar system"),e.hijriSystem=n)}return E=e,C()},exports.startOfDay=function(t){const e=N(t);return e.setHours(0,0,0,0),v(e,t,"startOfDay()")},exports.startOfMonth=function(t){const e=N(t);return e.setDate(1),e.setHours(0,0,0,0),v(e,t,"startOfMonth()")},exports.startOfYear=function(t){const e=N(t);return e.setMonth(0,1),e.setHours(0,0,0,0),v(e,t,"startOfYear()")},exports.subDays=function(t,e){return T(t,-e)},exports.subMonths=function(t,e){return x(t,-e)},exports.subYears=function(t,e){return j(t,-e)},exports.toBanglaCalendar=I,exports.toBanglaDigits=f,exports.toDate=N,exports.toEnglishDigits=y,exports.toHijriCalendar=O;
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,11 @@ type YearFormat = "numeric" | "2-digit";
|
|
|
5
5
|
type DayFormat = "numeric" | "2-digit";
|
|
6
6
|
type WeekdayFormat = "short" | "long";
|
|
7
7
|
type TimeFormat = "numeric" | "2-digit";
|
|
8
|
-
type
|
|
8
|
+
type StandardFormatPreset = "date" | "dateTime" | "isoLike";
|
|
9
|
+
type FormatMode = "standard" | "bangla" | "hijri" | "hybrid";
|
|
10
|
+
type HijriCalendarSystem = "islamic-umalqura" | "islamic-civil";
|
|
11
|
+
declare const HIJRI_TIME_ZONES: readonly ["Asia/Dhaka", "UTC"];
|
|
12
|
+
type HijriTimeZone = (typeof HIJRI_TIME_ZONES)[number];
|
|
9
13
|
type DateInput = Date | string | number;
|
|
10
14
|
interface DateFormatOptions {
|
|
11
15
|
locale?: Locale;
|
|
@@ -17,6 +21,7 @@ interface DateFormatOptions {
|
|
|
17
21
|
minute?: TimeFormat;
|
|
18
22
|
second?: TimeFormat;
|
|
19
23
|
hour12?: boolean;
|
|
24
|
+
preset?: StandardFormatPreset;
|
|
20
25
|
}
|
|
21
26
|
type PatternFormatOptions = {
|
|
22
27
|
pattern: string;
|
|
@@ -31,11 +36,16 @@ type BanglaFormatOptions = BanglaCalendarFormatOptions & {
|
|
|
31
36
|
mode: "bangla";
|
|
32
37
|
pattern?: never;
|
|
33
38
|
};
|
|
39
|
+
type HijriFormatOptions = HijriCalendarFormatOptions & {
|
|
40
|
+
mode: "hijri";
|
|
41
|
+
pattern?: never;
|
|
42
|
+
};
|
|
34
43
|
type HybridFormatOptions = HybridDateFormatOptions & {
|
|
35
44
|
mode: "hybrid";
|
|
36
45
|
pattern?: never;
|
|
37
46
|
};
|
|
38
|
-
type FormatOptions = PatternFormatOptions | StandardFormatOptions | BanglaFormatOptions | HybridFormatOptions;
|
|
47
|
+
type FormatOptions = PatternFormatOptions | StandardFormatOptions | BanglaFormatOptions | HijriFormatOptions | HybridFormatOptions;
|
|
48
|
+
type ResolvableFormatOptions = FormatOptions | Omit<StandardFormatOptions, "mode"> | Omit<BanglaFormatOptions, "mode"> | Omit<HijriFormatOptions, "mode"> | Omit<HybridFormatOptions, "mode">;
|
|
39
49
|
interface HybridDateFormatOptions {
|
|
40
50
|
digits?: Language;
|
|
41
51
|
month?: Language;
|
|
@@ -43,16 +53,66 @@ interface HybridDateFormatOptions {
|
|
|
43
53
|
day?: Language;
|
|
44
54
|
monthFormat?: MonthFormat;
|
|
45
55
|
}
|
|
56
|
+
type RelativeTimeStyle = "long" | "short";
|
|
57
|
+
interface RelativeTimeThresholdOptions {
|
|
58
|
+
justNow?: number;
|
|
59
|
+
minute?: number;
|
|
60
|
+
hour?: number;
|
|
61
|
+
day?: number;
|
|
62
|
+
week?: number;
|
|
63
|
+
month?: number;
|
|
64
|
+
year?: number;
|
|
65
|
+
}
|
|
46
66
|
interface RelativeTimeOptions {
|
|
47
67
|
locale?: Locale;
|
|
48
68
|
numeric?: "always" | "auto";
|
|
69
|
+
baseDate?: DateInput;
|
|
70
|
+
style?: RelativeTimeStyle;
|
|
71
|
+
threshold?: RelativeTimeThresholdOptions;
|
|
49
72
|
}
|
|
50
73
|
interface DateParseOptions {
|
|
51
74
|
calendar?: "gregorian" | "bangla";
|
|
75
|
+
strict?: boolean;
|
|
52
76
|
}
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
type DateParseFormat = "date_object" | "timestamp" | "ymd" | "iso_datetime" | "day_month_year" | "month_day_year" | "bangla_calendar";
|
|
78
|
+
type DateParseFailureReason = "invalid_date_object" | "invalid_timestamp" | "out_of_range" | "invalid_string" | "strict_mismatch" | "invalid_bangla_calendar_date";
|
|
79
|
+
interface DateParseSuccessResult {
|
|
80
|
+
success: true;
|
|
81
|
+
date: Date;
|
|
82
|
+
input: DateInput;
|
|
83
|
+
normalizedInput: string | number | null;
|
|
84
|
+
calendar: "gregorian" | "bangla";
|
|
85
|
+
strict: boolean;
|
|
86
|
+
format: DateParseFormat;
|
|
87
|
+
}
|
|
88
|
+
interface DateParseFailureResult {
|
|
89
|
+
success: false;
|
|
90
|
+
date: null;
|
|
91
|
+
input: DateInput;
|
|
92
|
+
normalizedInput: string | number | null;
|
|
93
|
+
calendar: "gregorian" | "bangla";
|
|
94
|
+
strict: boolean;
|
|
95
|
+
reason: DateParseFailureReason;
|
|
96
|
+
message: string;
|
|
97
|
+
}
|
|
98
|
+
type DateParseDetailedResult = DateParseSuccessResult | DateParseFailureResult;
|
|
99
|
+
interface GlobalDefaults {
|
|
100
|
+
locale: Locale;
|
|
101
|
+
mode: FormatMode;
|
|
102
|
+
month?: MonthFormat | undefined;
|
|
103
|
+
timeZone: HijriTimeZone;
|
|
104
|
+
hijriSystem: HijriCalendarSystem;
|
|
55
105
|
}
|
|
106
|
+
interface GlobalDefaultsInput {
|
|
107
|
+
locale?: Locale | null;
|
|
108
|
+
mode?: FormatMode | null;
|
|
109
|
+
month?: MonthFormat | null;
|
|
110
|
+
timeZone?: HijriTimeZone | null;
|
|
111
|
+
hijriSystem?: HijriCalendarSystem | null;
|
|
112
|
+
}
|
|
113
|
+
type BanglaCalendarOptions<TLocale extends Locale | undefined = Locale | undefined> = {
|
|
114
|
+
locale?: TLocale;
|
|
115
|
+
};
|
|
56
116
|
interface BanglaCalendarDate {
|
|
57
117
|
day: number;
|
|
58
118
|
month: string;
|
|
@@ -65,11 +125,35 @@ interface BanglaCalendarDateLocalized {
|
|
|
65
125
|
monthIndex: number;
|
|
66
126
|
year: string;
|
|
67
127
|
}
|
|
128
|
+
type BanglaCalendarResult<TLocale extends Locale | undefined = undefined> = TLocale extends "bn-BD" ? BanglaCalendarDateLocalized : TLocale extends "en-BD" | undefined ? BanglaCalendarDate : BanglaCalendarDate | BanglaCalendarDateLocalized;
|
|
68
129
|
interface BanglaCalendarFormatOptions {
|
|
69
130
|
locale?: Locale;
|
|
70
131
|
format?: BanglaCalendarDayFormat;
|
|
71
132
|
variant?: BanglaCalendarDaySpokenVariant;
|
|
72
133
|
}
|
|
134
|
+
type HijriCalendarOptions<TLocale extends Locale | undefined = Locale | undefined> = {
|
|
135
|
+
locale?: TLocale;
|
|
136
|
+
timeZone?: HijriTimeZone;
|
|
137
|
+
hijriSystem?: HijriCalendarSystem;
|
|
138
|
+
};
|
|
139
|
+
interface HijriCalendarDate {
|
|
140
|
+
day: number;
|
|
141
|
+
month: string;
|
|
142
|
+
monthIndex: number;
|
|
143
|
+
year: number;
|
|
144
|
+
}
|
|
145
|
+
interface HijriCalendarDateLocalized {
|
|
146
|
+
day: string;
|
|
147
|
+
month: string;
|
|
148
|
+
monthIndex: number;
|
|
149
|
+
year: string;
|
|
150
|
+
}
|
|
151
|
+
type HijriCalendarResult<TLocale extends Locale | undefined = undefined> = TLocale extends "bn-BD" ? HijriCalendarDateLocalized : TLocale extends "en-BD" | undefined ? HijriCalendarDate : HijriCalendarDate | HijriCalendarDateLocalized;
|
|
152
|
+
interface HijriCalendarFormatOptions {
|
|
153
|
+
locale?: Locale;
|
|
154
|
+
timeZone?: HijriTimeZone;
|
|
155
|
+
hijriSystem?: HijriCalendarSystem;
|
|
156
|
+
}
|
|
73
157
|
type BanglaCalendarDayFormat = "ordinal" | "spoken";
|
|
74
158
|
type BanglaCalendarDaySpokenVariant = "pohela" | "poyla";
|
|
75
159
|
interface BanglaDayFormatOptions {
|
|
@@ -77,12 +161,14 @@ interface BanglaDayFormatOptions {
|
|
|
77
161
|
variant?: BanglaCalendarDaySpokenVariant;
|
|
78
162
|
}
|
|
79
163
|
|
|
80
|
-
declare function toBanglaCalendar(input: DateInput, options
|
|
81
|
-
locale: "bn-BD";
|
|
82
|
-
}): BanglaCalendarDateLocalized;
|
|
83
|
-
declare function toBanglaCalendar(input: DateInput, options?: BanglaCalendarOptions): BanglaCalendarDate;
|
|
164
|
+
declare function toBanglaCalendar<TLocale extends Locale | undefined = undefined>(input: DateInput, options?: BanglaCalendarOptions<TLocale>): BanglaCalendarResult<TLocale>;
|
|
84
165
|
declare function fromBanglaCalendar(day: number, monthIndex: number, year: number): Date;
|
|
85
166
|
|
|
167
|
+
declare function getDefaults(): GlobalDefaults;
|
|
168
|
+
declare function setDefaults(input?: GlobalDefaultsInput): GlobalDefaults;
|
|
169
|
+
|
|
170
|
+
declare function toHijriCalendar<TLocale extends Locale | undefined = undefined>(input: DateInput, options?: HijriCalendarOptions<TLocale>): HijriCalendarResult<TLocale>;
|
|
171
|
+
|
|
86
172
|
declare const ENGLISH_DIGITS: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
87
173
|
declare const BANGLA_DIGITS: readonly ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"];
|
|
88
174
|
declare const ENGLISH_MONTHS_FULL: readonly ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
@@ -141,8 +227,9 @@ declare function toBanglaDigits(input: number | string): string;
|
|
|
141
227
|
declare function toEnglishDigits(input: number | string): string;
|
|
142
228
|
|
|
143
229
|
declare function formatBanglaCalendarDay(day: number, options?: BanglaDayFormatOptions): string;
|
|
144
|
-
declare function format(input: DateInput, options
|
|
230
|
+
declare function format(input: DateInput, options?: ResolvableFormatOptions): string;
|
|
145
231
|
|
|
232
|
+
declare function parseDateDetailed(input: DateInput, options?: DateParseOptions): DateParseDetailedResult;
|
|
146
233
|
declare function parseDate(input: DateInput, options?: DateParseOptions): Date | null;
|
|
147
234
|
|
|
148
235
|
declare function fromNow(input: DateInput, options?: RelativeTimeOptions): string;
|
|
@@ -165,4 +252,4 @@ declare function startOfYear(input: DateInput): Date;
|
|
|
165
252
|
declare function endOfYear(input: DateInput): Date;
|
|
166
253
|
declare function getBanglaMonth(month: number, format?: MonthFormat): string;
|
|
167
254
|
|
|
168
|
-
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type FormatMode, type FormatOptions, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type TimeFormat, type WeekdayFormat, type YearFormat, addDays, addMonths, addYears, endOfDay, endOfMonth, endOfYear, format, formatBanglaCalendarDay, fromBanglaCalendar, fromNow, getBanglaMonth, isToday, isTomorrow, isYesterday, parseDate, startOfDay, startOfMonth, startOfYear, subDays, subMonths, subYears, toBanglaCalendar, toBanglaDigits, toDate, toEnglishDigits };
|
|
255
|
+
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaCalendarResult, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseDetailedResult, type DateParseFailureReason, type DateParseFormat, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type FormatMode, type FormatOptions, type GlobalDefaults, type GlobalDefaultsInput, HIJRI_TIME_ZONES, type HijriCalendarDate, type HijriCalendarDateLocalized, type HijriCalendarFormatOptions, type HijriCalendarOptions, type HijriCalendarResult, type HijriCalendarSystem, type HijriFormatOptions, type HijriTimeZone, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type RelativeTimeStyle, type RelativeTimeThresholdOptions, type ResolvableFormatOptions, type StandardFormatPreset, type TimeFormat, type WeekdayFormat, type YearFormat, addDays, addMonths, addYears, endOfDay, endOfMonth, endOfYear, format, formatBanglaCalendarDay, fromBanglaCalendar, fromNow, getBanglaMonth, getDefaults, isToday, isTomorrow, isYesterday, parseDate, parseDateDetailed, setDefaults, startOfDay, startOfMonth, startOfYear, subDays, subMonths, subYears, toBanglaCalendar, toBanglaDigits, toDate, toEnglishDigits, toHijriCalendar };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ type YearFormat = "numeric" | "2-digit";
|
|
|
5
5
|
type DayFormat = "numeric" | "2-digit";
|
|
6
6
|
type WeekdayFormat = "short" | "long";
|
|
7
7
|
type TimeFormat = "numeric" | "2-digit";
|
|
8
|
-
type
|
|
8
|
+
type StandardFormatPreset = "date" | "dateTime" | "isoLike";
|
|
9
|
+
type FormatMode = "standard" | "bangla" | "hijri" | "hybrid";
|
|
10
|
+
type HijriCalendarSystem = "islamic-umalqura" | "islamic-civil";
|
|
11
|
+
declare const HIJRI_TIME_ZONES: readonly ["Asia/Dhaka", "UTC"];
|
|
12
|
+
type HijriTimeZone = (typeof HIJRI_TIME_ZONES)[number];
|
|
9
13
|
type DateInput = Date | string | number;
|
|
10
14
|
interface DateFormatOptions {
|
|
11
15
|
locale?: Locale;
|
|
@@ -17,6 +21,7 @@ interface DateFormatOptions {
|
|
|
17
21
|
minute?: TimeFormat;
|
|
18
22
|
second?: TimeFormat;
|
|
19
23
|
hour12?: boolean;
|
|
24
|
+
preset?: StandardFormatPreset;
|
|
20
25
|
}
|
|
21
26
|
type PatternFormatOptions = {
|
|
22
27
|
pattern: string;
|
|
@@ -31,11 +36,16 @@ type BanglaFormatOptions = BanglaCalendarFormatOptions & {
|
|
|
31
36
|
mode: "bangla";
|
|
32
37
|
pattern?: never;
|
|
33
38
|
};
|
|
39
|
+
type HijriFormatOptions = HijriCalendarFormatOptions & {
|
|
40
|
+
mode: "hijri";
|
|
41
|
+
pattern?: never;
|
|
42
|
+
};
|
|
34
43
|
type HybridFormatOptions = HybridDateFormatOptions & {
|
|
35
44
|
mode: "hybrid";
|
|
36
45
|
pattern?: never;
|
|
37
46
|
};
|
|
38
|
-
type FormatOptions = PatternFormatOptions | StandardFormatOptions | BanglaFormatOptions | HybridFormatOptions;
|
|
47
|
+
type FormatOptions = PatternFormatOptions | StandardFormatOptions | BanglaFormatOptions | HijriFormatOptions | HybridFormatOptions;
|
|
48
|
+
type ResolvableFormatOptions = FormatOptions | Omit<StandardFormatOptions, "mode"> | Omit<BanglaFormatOptions, "mode"> | Omit<HijriFormatOptions, "mode"> | Omit<HybridFormatOptions, "mode">;
|
|
39
49
|
interface HybridDateFormatOptions {
|
|
40
50
|
digits?: Language;
|
|
41
51
|
month?: Language;
|
|
@@ -43,16 +53,66 @@ interface HybridDateFormatOptions {
|
|
|
43
53
|
day?: Language;
|
|
44
54
|
monthFormat?: MonthFormat;
|
|
45
55
|
}
|
|
56
|
+
type RelativeTimeStyle = "long" | "short";
|
|
57
|
+
interface RelativeTimeThresholdOptions {
|
|
58
|
+
justNow?: number;
|
|
59
|
+
minute?: number;
|
|
60
|
+
hour?: number;
|
|
61
|
+
day?: number;
|
|
62
|
+
week?: number;
|
|
63
|
+
month?: number;
|
|
64
|
+
year?: number;
|
|
65
|
+
}
|
|
46
66
|
interface RelativeTimeOptions {
|
|
47
67
|
locale?: Locale;
|
|
48
68
|
numeric?: "always" | "auto";
|
|
69
|
+
baseDate?: DateInput;
|
|
70
|
+
style?: RelativeTimeStyle;
|
|
71
|
+
threshold?: RelativeTimeThresholdOptions;
|
|
49
72
|
}
|
|
50
73
|
interface DateParseOptions {
|
|
51
74
|
calendar?: "gregorian" | "bangla";
|
|
75
|
+
strict?: boolean;
|
|
52
76
|
}
|
|
53
|
-
|
|
54
|
-
|
|
77
|
+
type DateParseFormat = "date_object" | "timestamp" | "ymd" | "iso_datetime" | "day_month_year" | "month_day_year" | "bangla_calendar";
|
|
78
|
+
type DateParseFailureReason = "invalid_date_object" | "invalid_timestamp" | "out_of_range" | "invalid_string" | "strict_mismatch" | "invalid_bangla_calendar_date";
|
|
79
|
+
interface DateParseSuccessResult {
|
|
80
|
+
success: true;
|
|
81
|
+
date: Date;
|
|
82
|
+
input: DateInput;
|
|
83
|
+
normalizedInput: string | number | null;
|
|
84
|
+
calendar: "gregorian" | "bangla";
|
|
85
|
+
strict: boolean;
|
|
86
|
+
format: DateParseFormat;
|
|
87
|
+
}
|
|
88
|
+
interface DateParseFailureResult {
|
|
89
|
+
success: false;
|
|
90
|
+
date: null;
|
|
91
|
+
input: DateInput;
|
|
92
|
+
normalizedInput: string | number | null;
|
|
93
|
+
calendar: "gregorian" | "bangla";
|
|
94
|
+
strict: boolean;
|
|
95
|
+
reason: DateParseFailureReason;
|
|
96
|
+
message: string;
|
|
97
|
+
}
|
|
98
|
+
type DateParseDetailedResult = DateParseSuccessResult | DateParseFailureResult;
|
|
99
|
+
interface GlobalDefaults {
|
|
100
|
+
locale: Locale;
|
|
101
|
+
mode: FormatMode;
|
|
102
|
+
month?: MonthFormat | undefined;
|
|
103
|
+
timeZone: HijriTimeZone;
|
|
104
|
+
hijriSystem: HijriCalendarSystem;
|
|
55
105
|
}
|
|
106
|
+
interface GlobalDefaultsInput {
|
|
107
|
+
locale?: Locale | null;
|
|
108
|
+
mode?: FormatMode | null;
|
|
109
|
+
month?: MonthFormat | null;
|
|
110
|
+
timeZone?: HijriTimeZone | null;
|
|
111
|
+
hijriSystem?: HijriCalendarSystem | null;
|
|
112
|
+
}
|
|
113
|
+
type BanglaCalendarOptions<TLocale extends Locale | undefined = Locale | undefined> = {
|
|
114
|
+
locale?: TLocale;
|
|
115
|
+
};
|
|
56
116
|
interface BanglaCalendarDate {
|
|
57
117
|
day: number;
|
|
58
118
|
month: string;
|
|
@@ -65,11 +125,35 @@ interface BanglaCalendarDateLocalized {
|
|
|
65
125
|
monthIndex: number;
|
|
66
126
|
year: string;
|
|
67
127
|
}
|
|
128
|
+
type BanglaCalendarResult<TLocale extends Locale | undefined = undefined> = TLocale extends "bn-BD" ? BanglaCalendarDateLocalized : TLocale extends "en-BD" | undefined ? BanglaCalendarDate : BanglaCalendarDate | BanglaCalendarDateLocalized;
|
|
68
129
|
interface BanglaCalendarFormatOptions {
|
|
69
130
|
locale?: Locale;
|
|
70
131
|
format?: BanglaCalendarDayFormat;
|
|
71
132
|
variant?: BanglaCalendarDaySpokenVariant;
|
|
72
133
|
}
|
|
134
|
+
type HijriCalendarOptions<TLocale extends Locale | undefined = Locale | undefined> = {
|
|
135
|
+
locale?: TLocale;
|
|
136
|
+
timeZone?: HijriTimeZone;
|
|
137
|
+
hijriSystem?: HijriCalendarSystem;
|
|
138
|
+
};
|
|
139
|
+
interface HijriCalendarDate {
|
|
140
|
+
day: number;
|
|
141
|
+
month: string;
|
|
142
|
+
monthIndex: number;
|
|
143
|
+
year: number;
|
|
144
|
+
}
|
|
145
|
+
interface HijriCalendarDateLocalized {
|
|
146
|
+
day: string;
|
|
147
|
+
month: string;
|
|
148
|
+
monthIndex: number;
|
|
149
|
+
year: string;
|
|
150
|
+
}
|
|
151
|
+
type HijriCalendarResult<TLocale extends Locale | undefined = undefined> = TLocale extends "bn-BD" ? HijriCalendarDateLocalized : TLocale extends "en-BD" | undefined ? HijriCalendarDate : HijriCalendarDate | HijriCalendarDateLocalized;
|
|
152
|
+
interface HijriCalendarFormatOptions {
|
|
153
|
+
locale?: Locale;
|
|
154
|
+
timeZone?: HijriTimeZone;
|
|
155
|
+
hijriSystem?: HijriCalendarSystem;
|
|
156
|
+
}
|
|
73
157
|
type BanglaCalendarDayFormat = "ordinal" | "spoken";
|
|
74
158
|
type BanglaCalendarDaySpokenVariant = "pohela" | "poyla";
|
|
75
159
|
interface BanglaDayFormatOptions {
|
|
@@ -77,12 +161,14 @@ interface BanglaDayFormatOptions {
|
|
|
77
161
|
variant?: BanglaCalendarDaySpokenVariant;
|
|
78
162
|
}
|
|
79
163
|
|
|
80
|
-
declare function toBanglaCalendar(input: DateInput, options
|
|
81
|
-
locale: "bn-BD";
|
|
82
|
-
}): BanglaCalendarDateLocalized;
|
|
83
|
-
declare function toBanglaCalendar(input: DateInput, options?: BanglaCalendarOptions): BanglaCalendarDate;
|
|
164
|
+
declare function toBanglaCalendar<TLocale extends Locale | undefined = undefined>(input: DateInput, options?: BanglaCalendarOptions<TLocale>): BanglaCalendarResult<TLocale>;
|
|
84
165
|
declare function fromBanglaCalendar(day: number, monthIndex: number, year: number): Date;
|
|
85
166
|
|
|
167
|
+
declare function getDefaults(): GlobalDefaults;
|
|
168
|
+
declare function setDefaults(input?: GlobalDefaultsInput): GlobalDefaults;
|
|
169
|
+
|
|
170
|
+
declare function toHijriCalendar<TLocale extends Locale | undefined = undefined>(input: DateInput, options?: HijriCalendarOptions<TLocale>): HijriCalendarResult<TLocale>;
|
|
171
|
+
|
|
86
172
|
declare const ENGLISH_DIGITS: readonly ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
87
173
|
declare const BANGLA_DIGITS: readonly ["০", "১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯"];
|
|
88
174
|
declare const ENGLISH_MONTHS_FULL: readonly ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
@@ -141,8 +227,9 @@ declare function toBanglaDigits(input: number | string): string;
|
|
|
141
227
|
declare function toEnglishDigits(input: number | string): string;
|
|
142
228
|
|
|
143
229
|
declare function formatBanglaCalendarDay(day: number, options?: BanglaDayFormatOptions): string;
|
|
144
|
-
declare function format(input: DateInput, options
|
|
230
|
+
declare function format(input: DateInput, options?: ResolvableFormatOptions): string;
|
|
145
231
|
|
|
232
|
+
declare function parseDateDetailed(input: DateInput, options?: DateParseOptions): DateParseDetailedResult;
|
|
146
233
|
declare function parseDate(input: DateInput, options?: DateParseOptions): Date | null;
|
|
147
234
|
|
|
148
235
|
declare function fromNow(input: DateInput, options?: RelativeTimeOptions): string;
|
|
@@ -165,4 +252,4 @@ declare function startOfYear(input: DateInput): Date;
|
|
|
165
252
|
declare function endOfYear(input: DateInput): Date;
|
|
166
253
|
declare function getBanglaMonth(month: number, format?: MonthFormat): string;
|
|
167
254
|
|
|
168
|
-
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type FormatMode, type FormatOptions, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type TimeFormat, type WeekdayFormat, type YearFormat, addDays, addMonths, addYears, endOfDay, endOfMonth, endOfYear, format, formatBanglaCalendarDay, fromBanglaCalendar, fromNow, getBanglaMonth, isToday, isTomorrow, isYesterday, parseDate, startOfDay, startOfMonth, startOfYear, subDays, subMonths, subYears, toBanglaCalendar, toBanglaDigits, toDate, toEnglishDigits };
|
|
255
|
+
export { BANGLA_CALENDAR_MONTHS, BANGLA_CALENDAR_MONTHS_EN, BANGLA_CALENDAR_MONTH_DAYS, BANGLA_DIGITS, BANGLA_MONTHS_FULL, BANGLA_MONTHS_SHORT, BANGLA_WEEKDAYS_FULL, BANGLA_WEEKDAYS_SHORT, BOISHAKH_START_DAY, BOISHAKH_START_MONTH, type BanglaCalendarDate, type BanglaCalendarDateLocalized, type BanglaCalendarDayFormat, type BanglaCalendarDaySpokenVariant, type BanglaCalendarFormatOptions, type BanglaCalendarOptions, type BanglaCalendarResult, type BanglaDayFormatOptions, type DateFormatOptions, type DateInput, type DateParseDetailedResult, type DateParseFailureReason, type DateParseFormat, type DateParseOptions, type DayFormat, ENGLISH_DIGITS, ENGLISH_MONTHS_FULL, ENGLISH_MONTHS_SHORT, ENGLISH_WEEKDAYS_FULL, ENGLISH_WEEKDAYS_SHORT, type FormatMode, type FormatOptions, type GlobalDefaults, type GlobalDefaultsInput, HIJRI_TIME_ZONES, type HijriCalendarDate, type HijriCalendarDateLocalized, type HijriCalendarFormatOptions, type HijriCalendarOptions, type HijriCalendarResult, type HijriCalendarSystem, type HijriFormatOptions, type HijriTimeZone, type HybridDateFormatOptions, type Language, type Locale, type MonthFormat, RELATIVE_TIME_BN, RELATIVE_TIME_EN, type RelativeTimeOptions, type RelativeTimeStyle, type RelativeTimeThresholdOptions, type ResolvableFormatOptions, type StandardFormatPreset, type TimeFormat, type WeekdayFormat, type YearFormat, addDays, addMonths, addYears, endOfDay, endOfMonth, endOfYear, format, formatBanglaCalendarDay, fromBanglaCalendar, fromNow, getBanglaMonth, getDefaults, isToday, isTomorrow, isYesterday, parseDate, parseDateDetailed, setDefaults, startOfDay, startOfMonth, startOfYear, subDays, subMonths, subYears, toBanglaCalendar, toBanglaDigits, toDate, toEnglishDigits, toHijriCalendar };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],i=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],s=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],l=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],c=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],d=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],g=[31,31,31,31,31,30,30,30,30,30,30,30],h=3,f=14,m={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},y={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function b(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function D(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var M={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11,"জানু":0,"ফেব্রু":1,"এপ্রি":3,"জুলা":6,"আগ":7,"সেপ্টে":8,"অক্টো":9,"নভে":10,"ডিসে":11};function w(t){const e=t.trim(),o=e.toLowerCase(),a=M[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;for(let t=0;t<i.length;t++)if(i[t]===e)return t;return-1}function p(t,e,n,r=0,o=0,a=0,u=0){const i=new Date(t,e,n,r,o,a,u);return i.getFullYear()!==t||i.getMonth()!==e||i.getDate()!==n||i.getHours()!==r||i.getMinutes()!==o||i.getSeconds()!==a||i.getMilliseconds()!==u?null:i}function $(t){return function(t){const e=t.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?p(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),u=Number(e[5]??0),i=Number(e[6]??0),s=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),l=e[8];if(void 0===l)return p(n,r-1,o,a,u,i,s);const c=l.match(/^([+-])(\d{2}):?(\d{2})$/),d=c?Number(c[2]):null,g=c?Number(c[3]):null,h="Z"===l?0:c&&null!==d&&null!==g&&d<=23&&g<=59?("+"===c[1]?1:-1)*(60*d+g):null;if(null===h)return null;const f=Date.UTC(n,r-1,o,a,u,i,s)-6e4*h,m=new Date(f),y=new Date(f+6e4*h);return y.getUTCFullYear()!==n||y.getUTCMonth()!==r-1||y.getUTCDate()!==o||y.getUTCHours()!==a||y.getUTCMinutes()!==u||y.getUTCSeconds()!==i||y.getUTCMilliseconds()!==s?null:m}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=w(r);if(-1===a)return null;let u=Number(o);return 2===o.length&&(u+=u>=50?1900:2e3),p(u,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=w(n);if(-1===a)return null;let u=Number(o);return 2===o.length&&(u+=u>=50?1900:2e3),p(u,a,r)}(t)}function v(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return new Date(e)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime()))throw new Error(`Invalid date input: ${String(t)}`);return e}const e=$(D(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return e}function N(t){const e=v(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Y(t){const e=v(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function S(t){const e=v(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function F(t){const e=v(t);return e.setHours(0,0,0,0),e}function k(t){const e=v(t);return e.setHours(23,59,59,999),e}function j(t,e){const n=v(t);return n.setDate(n.getDate()+e),n}function T(t,e){return j(t,-e)}function B(t,e){return new Date(t,e+1,0).getDate()}function H(t,e){const n=v(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),u=(o%12+12)%12,i=Math.min(n.getDate(),B(a,u));return n.setFullYear(a,u,i),n}function C(t,e){return H(t,-e)}function I(t,e){const n=v(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),B(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),n}function E(t,e){return I(t,-e)}function x(t){const e=v(t);return e.setDate(1),e.setHours(0,0,0,0),e}function A(t){const e=v(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),e}function U(t){const e=v(t);return e.setMonth(0,1),e.setHours(0,0,0,0),e}function J(t){const e=v(t);return e.setMonth(11,31),e.setHours(23,59,59,999),e}function L(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?i[n]:u[n]}function O(t){const e=[...g];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function P(t,e){const n=e?.locale??"en-BD",r=v(t),o=r.getFullYear(),a=r.getMonth(),u=r.getDate(),i=new Date(o,3,14),s=a<3||3===a&&u<14,l=s?o-594:o-593,g=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(s?new Date(o-1,3,14):i,r)+1,h=O(l);let f=g,m=0;for(let t=0;t<h.length;t++){const e=h[t];if(f<=e){m=t;break}f-=e}const y=m+1;return"bn-BD"===n?{day:b(f),month:c[m],monthIndex:y,year:b(l)}:{day:f,month:d[m],monthIndex:y,year:l}}function W(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=O(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const u=new Date(o);return u.setDate(u.getDate()+a),u}function Z(t){const e=b(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function K(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return Z(t)}}(t,e?.variant):Z(t)}function q(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function z(t,e,n){const r=q(t,n);return"bn-BD"===e?b(r):r}function G(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}`)}function Q(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}function R(t,e){if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError("format() expects an options object");if("pattern"in e&&void 0!==e.pattern){if("mode"in e&&void 0!==e.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const c="locale"in e&&void 0!==e.locale?e.locale:"en-BD";return function(t,e,c="en-BD"){const d=v(t),g="bn-BD"===c,h=d.getDate(),f=d.getMonth(),m=d.getFullYear(),y=g?u:n,b=g?i:r,D=g?s:o,M=g?l:a,w=d.getHours(),p=w%12||12,$={dddd:D[d.getDay()],ddd:M[d.getDay()],MMMM:y[f],MMM:b[f],MM:z(f+1,c,"2-digit"),M:z(f+1,c,"numeric"),DD:z(h,c,"2-digit"),D:z(h,c,"numeric"),HH:z(w,c,"2-digit"),H:z(w,c,"numeric"),hh:z(p,c,"2-digit"),h:z(p,c,"numeric"),mm:z(d.getMinutes(),c,"2-digit"),m:z(d.getMinutes(),c,"numeric"),ss:z(d.getSeconds(),c,"2-digit"),s:z(d.getSeconds(),c,"numeric"),A:Q(w,c,!1),a:Q(w,c,!0),YYYY:z(m,c,"numeric"),YY:z(Number(String(m).slice(-2)),c,"2-digit")},N=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,Y=t=>t.replace(N,t=>$[t]);let S="",F=0;for(;F<e.length;){const t=e.indexOf("[",F);if(-1===t){S+=Y(e.slice(F));break}S+=Y(e.slice(F,t));const n=e.indexOf("]",t+1);if(-1===n){S+=e.slice(t);break}S+=e.slice(t+1,n),F=n+1}return S}(t,e.pattern,c)}if(!("mode"in e)||void 0===e.mode)throw new TypeError("format() expects `mode` or `pattern`");const d=e.mode;switch(d){case"standard":return function(t,e){const c=v(t),d=e?.locale??"en-BD",g=e?.month??"short",h=e?.year??"numeric",f=e?.day??"numeric",m=e?.weekday,y=e?.hour,D=e?.minute,M=e?.second,w=void 0!==y||void 0!==D||void 0!==M,p="bn-BD"===d;G(g,["short","long"],"month format for standard mode"),G(h,["numeric","2-digit"],"year format for standard mode"),G(f,["numeric","2-digit"],"day format for standard mode"),void 0!==m&&G(m,["short","long"],"weekday format for standard mode"),void 0!==y&&G(y,["numeric","2-digit"],"hour format for standard mode"),void 0!==D&&G(D,["numeric","2-digit"],"minute format for standard mode"),void 0!==M&&G(M,["numeric","2-digit"],"second format for standard mode");const $=c.getDate(),N=c.getMonth(),Y=c.getFullYear(),S=`${"2-digit"===f?String($).padStart(2,"0"):String($)} ${(p?"short"===g?i:u:"short"===g?r:n)[N]} ${"2-digit"===h?String(Y).slice(-2):String(Y)}`,F=void 0!==m?`${(p?"short"===m?l:s:"short"===m?a:o)[c.getDay()]}, `:"";let k="";if(w){const t=e?.hour12??!1,n=c.getHours(),r=D??(void 0!==M?"2-digit":void 0);k=`${q(t?n%12||12:n,y??"numeric")}${void 0!==r?`:${q(c.getMinutes(),r)}`:""}${void 0!==M?`:${q(c.getSeconds(),M)}`:""}${t?` ${Q(n,d,!1)}`:""}`}const j=`${F}${S}${k?`, ${k}`:""}`;return p?b(j):j}(t,e);case"bangla":return function(t,e){const n=e?.locale??"en-BD",r=e?.format??"ordinal",o=e?.variant,a=P(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${K(a.day,e)} ${c[t]} ${b(a.year)}`}return`${a.day} ${a.month} ${a.year}`}(t,e);case"hybrid":return function(t,e){const o=v(t),a=e?.digits??"en",s=e?.month??"bn",l=e?.year??"en",c=e?.day??a,d=e?.monthFormat??"long";G(a,["en","bn"],"digits language for hybrid mode"),G(s,["en","bn"],"month language for hybrid mode"),G(l,["en","bn"],"year language for hybrid mode"),G(c,["en","bn"],"day language for hybrid mode"),G(d,["short","long"],"month format for hybrid mode");const g=o.getDate(),h=o.getMonth(),f=o.getFullYear(),m="bn"===s?"short"===d?i:u:"short"===d?r:n,y="bn"===c?b(g):String(g),D=m[h],M="bn"===l?b(f):String(f);return`${y} ${D} ${M}`}(t,e);default:throw new TypeError(`Invalid format mode: ${String(d)}`)}}var V={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},X={"বৈশাখ":1,"জৈষ্ঠ":2,"জ্যৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ়":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12};function _(t,e){if(t instanceof Date)return Number.isNaN(t.getTime())?null:new Date(t.getTime());if("number"==typeof t){const e=new Date(t);return Number.isNaN(e.getTime())?null:e}const n=D(t).trim();return"bangla"===e?.calendar?function(t){const e=t.match(/^(\S+),?\s+(\S+),?\s+(\d{4})$/);if(!e)return null;const n=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=Number(t);return Number.isInteger(r)&&r>=1&&r<=31?r:null}(e[1].replace(/,$/,""));if(null===n)return null;const r=function(t){const e=t.toLowerCase();for(let e=0;e<c.length;e++)if(c[e]===t)return e+1;const n=X[t];if(void 0!==n)return n;for(let t=0;t<d.length;t++)if(d[t].toLowerCase()===e)return t+1;const r=V[e];return void 0!==r?r:-1}(e[2].replace(/,$/,""));if(-1===r)return null;const o=Number(e[3]);try{return W(n,r,o)}catch{return null}}(n):$(n)}var tt=1e3,et=36e5,nt=24*et,rt=[{threshold:7*nt,singular:"week",plural:"weeks"},{threshold:nt,singular:"day",plural:"days"},{threshold:et,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:tt,singular:"second",plural:"seconds"}];function ot(t,e){return new Date(t,e+1,0).getDate()}function at(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),ot(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function ut(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,u=Math.min(t.getDate(),ot(o,a));return new Date(o,a,u,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function it(t,e,n,r,o){const a="bn-BD"===o,u=a?b(t):String(t),i=1===t?e:n;return a?r?`${u} ${i} আগে`:`${u} ${i} পরে`:r?`${u} ${i} ago`:`in ${u} ${i}`}function st(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}function lt(t,e){const n=v(t),r=e?.locale??"en-BD",o=e?.numeric??"always",a="bn-BD"===r?y:m,u=Date.now()-n.getTime(),i=Math.abs(u),s=u>0,l=new Date,c=n.getFullYear()===l.getFullYear()&&n.getMonth()===l.getMonth()&&n.getDate()===l.getDate(),d=s?l:n,g=s?n:l;if(i<tt)return a.justNow;if("auto"===o&&c)return function(t){return"bn-BD"===t?"আজ":"today"}(r);const h=at(d,g);if(h>=1){if("auto"===o&&1===h){const t=st("year",s,r);if(null!==t)return t}return it(h,a.year,a.years,s,r)}const f=ut(d,g);if(f>=1){if("auto"===o&&1===f){const t=st("month",s,r);if(null!==t)return t}return it(f,a.month,a.months,s,r)}for(const t of rt)if(i>=t.threshold){const e=Math.floor(i/t.threshold);if("auto"===o&&1===e&&("day"===t.singular||"week"===t.singular)){const e=st(t.singular,s,r);if(null!==e)return e}return it(e,a[t.singular],a[t.plural],s,r)}return a.justNow}export{c as BANGLA_CALENDAR_MONTHS,d as BANGLA_CALENDAR_MONTHS_EN,g as BANGLA_CALENDAR_MONTH_DAYS,e as BANGLA_DIGITS,u as BANGLA_MONTHS_FULL,i as BANGLA_MONTHS_SHORT,s as BANGLA_WEEKDAYS_FULL,l as BANGLA_WEEKDAYS_SHORT,f as BOISHAKH_START_DAY,h as BOISHAKH_START_MONTH,t as ENGLISH_DIGITS,n as ENGLISH_MONTHS_FULL,r as ENGLISH_MONTHS_SHORT,o as ENGLISH_WEEKDAYS_FULL,a as ENGLISH_WEEKDAYS_SHORT,y as RELATIVE_TIME_BN,m as RELATIVE_TIME_EN,j as addDays,H as addMonths,I as addYears,k as endOfDay,A as endOfMonth,J as endOfYear,R as format,K as formatBanglaCalendarDay,W as fromBanglaCalendar,lt as fromNow,L as getBanglaMonth,N as isToday,S as isTomorrow,Y as isYesterday,_ as parseDate,F as startOfDay,x as startOfMonth,U as startOfYear,T as subDays,C as subMonths,E as subYears,P as toBanglaCalendar,b as toBanglaDigits,v as toDate,D as toEnglishDigits};
|
|
1
|
+
var t=["0","1","2","3","4","5","6","7","8","9"],e=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],n=["January","February","March","April","May","June","July","August","September","October","November","December"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],o=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],u=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],s=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],d=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],l=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],c=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],m=[31,31,31,31,31,30,30,30,30,30,30,30],h=3,g=14,f={second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",day:"day",days:"days",week:"week",weeks:"weeks",month:"month",months:"months",year:"year",years:"years",ago:"ago",in:"in",justNow:"just now"},y={second:"সেকেন্ড",seconds:"সেকেন্ড",minute:"মিনিট",minutes:"মিনিট",hour:"ঘণ্টা",hours:"ঘণ্টা",day:"দিন",days:"দিন",week:"সপ্তাহ",weeks:"সপ্তাহ",month:"মাস",months:"মাস",year:"বছর",years:"বছর",ago:"আগে",in:"",justNow:"এইমাত্র"};function b(t){return String(t).replace(/\d/g,t=>e[Number(t)]??t)}function w(n){return String(n).replace(/[০-৯]/g,n=>{const r=e.indexOf(n);return r>=0?t[r]??n:n})}var p={jan:0,"jan.":0,january:0,"january,":0,feb:1,"feb.":1,february:1,"february,":1,mar:2,"mar.":2,march:2,"march,":2,apr:3,"apr.":3,april:3,"april,":3,may:4,"may,":4,jun:5,"jun.":5,june:5,"june,":5,jul:6,"jul.":6,july:6,"july,":6,aug:7,"aug.":7,august:7,"august,":7,sep:8,sept:8,"sep.":8,"sept.":8,september:8,"september,":8,oct:9,"oct.":9,october:9,"october,":9,nov:10,"nov.":10,november:10,"november,":10,dec:11,"dec.":11,december:11,"december,":11,"জানুয়ারি":0,"জানুয়ারি":0,"ফেব্রুয়ারি":1,"ফেব্রুয়ারি":1,"মার্চ":2,"এপ্রিল":3,"মে":4,"জুন":5,"জুলাই":6,"আগস্ট":7,"অগাস্ট":7,"সেপ্টেম্বর":8,"সেপ্টেম্বার":8,"অক্টোবর":9,"নভেম্বর":10,"নভেম্বার":10,"ডিসেম্বর":11,"ডিসেম্বার":11};function $(t){const e=t.trim(),o=e.toLowerCase(),a=p[o];if(void 0!==a)return a;for(let t=0;t<n.length;t++)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t++)if(r[t].toLowerCase()===o)return t;for(let t=0;t<i.length;t++)if(i[t]===e)return t;for(let t=0;t<u.length;t++)if(u[t]===e)return t;return-1}function D(t){return Number.isFinite(t)&&Math.abs(t)<=864e13}function v(t,e,n,r=0,o=0,a=0,i=0){const u=new Date(0);return u.setUTCFullYear(t,e,n),u.setUTCHours(r,o,a,i),u.getUTCFullYear()!==t||u.getUTCMonth()!==e||u.getUTCDate()!==n||u.getUTCHours()!==r||u.getUTCMinutes()!==o||u.getUTCSeconds()!==a||u.getUTCMilliseconds()!==i?null:u}function M(t,e,n,r=0,o=0,a=0,i=0){return function(t,e,n,r=0,o=0,a=0,i=0){const u=new Date(0);return u.setFullYear(t,e,n),u.setHours(r,o,a,i),u.getFullYear()!==t||u.getMonth()!==e||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==i?null:u}(t,e,n,r,o,a,i)??v(t,e,n,r,o,a,i)}function S(t){if(!/^[+-]?\d+$/.test(t))return null;const e=Number(t);return Number.isInteger(e)?e:null}function j(t){return function(t){const e=t.trim().match(/^([+-]\d{6}|\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return e?M(Number(e[1]),Number(e[3])-1,Number(e[4])):null}(t)??function(t){const e=t.trim().match(/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!e)return null;const n=Number(e[1]),r=Number(e[2]),o=Number(e[3]),a=Number(e[4]??0),i=Number(e[5]??0),u=Number(e[6]??0),s=Number((e[7]??"0").padEnd(3,"0").slice(0,3)),d=e[8];if(void 0===d)return M(n,r-1,o,a,i,u,s);const l=d.match(/^([+-])(\d{2}):?(\d{2})$/),c=l?Number(l[2]):null,m=l?Number(l[3]):null,h="Z"===d?0:l&&null!==c&&null!==m&&c<=23&&m<=59?("+"===l[1]?1:-1)*(60*c+m):null;if(null===h)return null;const g=v(n,r-1,o,a,i,u,s);if(!g)return null;const f=g.getTime()-6e4*h;if(!D(f))return null;const y=new Date(f),b=new Date(f+6e4*h);return b.getUTCFullYear()!==n||b.getUTCMonth()!==r-1||b.getUTCDate()!==o||b.getUTCHours()!==a||b.getUTCMinutes()!==i||b.getUTCSeconds()!==u||b.getUTCMilliseconds()!==s?null:y}(t)??function(t){const e=t.match(/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4}|\d{2})$/);if(!e)return null;const n=Number(e[1]),r=e[2].replace(/,$/,""),o=e[3],a=$(r);if(-1===a)return null;const i=S(o);if(null===i)return null;let u=i;return o.startsWith("+")||o.startsWith("-")||2!==o.length||(u+=u>=50?1900:2e3),M(u,a,n)}(t)??function(t){const e=t.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4}|\d{2})$/);if(!e)return null;const n=e[1].replace(/,$/,""),r=Number(e[2]),o=e[3],a=$(n);if(-1===a)return null;const i=S(o);if(null===i)return null;let u=i;return o.startsWith("+")||o.startsWith("-")||2!==o.length||(u+=u>=50?1900:2e3),M(u,a,r)}(t)}function N(t,e,n){if(!D(t.getTime())){throw new RangeError(`${void 0===n?"Date input":`${n} output`} is outside the supported range: ${String(e)}`)}return t}function T(t){if(t instanceof Date){const e=t.getTime();if(Number.isNaN(e))throw new Error(`Invalid date input: ${String(t)}`);return N(new Date(e),t)}if("number"==typeof t){if(!Number.isFinite(t))throw new Error(`Invalid date input: ${String(t)}`);const e=new Date(t);if(Number.isNaN(e.getTime())){if(!D(t))throw new RangeError(`Date input is outside the supported range: ${String(t)}`);throw new Error(`Invalid date input: ${String(t)}`)}return N(e,t)}const e=j(w(t).trim());if(!e)throw new Error(`Invalid date input: ${String(t)}`);return N(e,t)}function Y(t){const e=T(t),n=new Date;return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function F(t){const e=T(t),n=new Date;return n.setDate(n.getDate()-1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function k(t){const e=T(t),n=new Date;return n.setDate(n.getDate()+1),e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function B(t){const e=T(t);return e.setHours(0,0,0,0),N(e,t,"startOfDay()")}function I(t){const e=T(t);return e.setHours(23,59,59,999),N(e,t,"endOfDay()")}function C(t,e){const n=T(t);return n.setDate(n.getDate()+e),N(n,t,"addDays()")}function _(t,e){return C(t,-e)}function H(t,e){return new Date(t,e+1,0).getDate()}function E(t,e){const n=T(t),r=n.getFullYear(),o=n.getMonth()+e,a=r+Math.floor(o/12),i=(o%12+12)%12,u=Math.min(n.getDate(),H(a,i));return n.setFullYear(a,i,u),N(n,t,"addMonths()")}function U(t,e){return E(t,-e)}function Z(t,e){const n=T(t),r=n.getFullYear()+e,o=Math.min(n.getDate(),H(r,n.getMonth()));return n.setFullYear(r,n.getMonth(),o),N(n,t,"addYears()")}function x(t,e){return Z(t,-e)}function A(t){const e=T(t);return e.setDate(1),e.setHours(0,0,0,0),N(e,t,"startOfMonth()")}function L(t){const e=T(t);return e.setMonth(e.getMonth()+1,0),e.setHours(23,59,59,999),N(e,t,"endOfMonth()")}function O(t){const e=T(t);return e.setMonth(0,1),e.setHours(0,0,0,0),N(e,t,"startOfYear()")}function J(t){const e=T(t);return e.setMonth(11,31),e.setHours(23,59,59,999),N(e,t,"endOfYear()")}function R(t,e="long"){const n=t-1;if(n<0||n>11)throw new Error(`Invalid month number: ${t}. Must be 1-12.`);return"short"===e?u[n]:i[n]}function W(t){const e=[...m];return function(t){return(e=t+594)%4==0&&e%100!=0||e%400==0;var e}(t)&&(e[10]=31),e}function q(t,e){const n=e?.locale??"en-BD",r=T(t),o=r.getFullYear(),a=r.getMonth(),i=r.getDate(),u=new Date(o,3,14),s=a<3||3===a&&i<14,d=s?o-594:o-593,m=function(t,e){const n=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()),r=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate());return Math.floor((r-n)/864e5)}(s?new Date(o-1,3,14):u,r)+1,h=W(d);let g=m,f=0;for(let t=0;t<h.length;t++){const e=h[t];if(g<=e){f=t;break}g-=e}const y=f+1;return"bn-BD"===n?{day:b(g),month:l[f],monthIndex:y,year:b(d)}:{day:g,month:c[f],monthIndex:y,year:d}}function z(t,e,n){const r=function(t,e,n){if(!Number.isInteger(t)||!Number.isInteger(e)||!Number.isInteger(n))throw new Error("Invalid Bangla calendar date.");if(e<1||e>12)throw new Error("Invalid Bangla calendar month index. Must be 1-12.");const r=W(n),o=r[e-1];if(t<1||t>o)throw new Error(`Invalid Bangla calendar day. Month ${e} of year ${n} has ${o} days.`);return r}(t,e,n),o=new Date(n+593,3,14);let a=t-1;for(let t=0;t<e-1;t++)a+=r[t];const i=new Date(o);return i.setDate(i.getDate()+a),N(i,{day:t,monthIndex:e,year:n},"fromBanglaCalendar()")}var P=["Asia/Dhaka","UTC"],G={locale:"en-BD",mode:"standard",month:void 0,timeZone:"Asia/Dhaka",hijriSystem:"islamic-umalqura"},K={...G};function Q(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}. Supported values: ${e.join(", ")}`)}function V(t,e){return null===e?G[t]:void 0!==e?e:void 0}function X(){return{...K}}function tt(t={}){const e={...K};if("locale"in t){const n=V("locale",t.locale);void 0!==n&&(Q(n,["en-BD","bn-BD"],"default locale"),e.locale=n)}if("mode"in t){const n=V("mode",t.mode);void 0!==n&&(Q(n,["standard","bangla","hijri","hybrid"],"default mode"),e.mode=n)}if("month"in t){const n=V("month",t.month);void 0===n?e.month=void 0:(Q(n,["short","long"],"default month format"),e.month=n)}if("timeZone"in t){const n=V("timeZone",t.timeZone);void 0!==n&&(Q(n,P,"default Hijri time zone"),e.timeZone=n)}if("hijriSystem"in t){const n=V("hijriSystem",t.hijriSystem);void 0!==n&&(Q(n,["islamic-umalqura","islamic-civil"],"default Hijri calendar system"),e.hijriSystem=n)}return K=e,X()}function et(t,e){const n=t.find(t=>t.type===e);if(void 0===n)throw new Error(`Missing ${e} part while formatting Hijri date.`);return n.value}function nt(t,e){const n=X(),r=e?.locale??"en-BD",o=e?.timeZone??n.timeZone,a=e?.hijriSystem??n.hijriSystem;!function(t){if(!P.includes(t))throw new RangeError(`Unsupported Hijri time zone: ${t}. Supported values: ${P.join(", ")}`)}(o),function(t){if(!["islamic-umalqura","islamic-civil"].includes(t))throw new RangeError(`Unsupported Hijri calendar system: ${t}. Supported values: islamic-umalqura, islamic-civil`)}(a);const i=function(t,e,n,r){const o=function(t,e){return`${t}-u-ca-${e}`}(e,r),a=new Intl.DateTimeFormat(o,{day:"numeric",month:"numeric",year:"numeric",timeZone:n}).formatToParts(t),i=new Intl.DateTimeFormat(o,{day:"numeric",month:"long",year:"numeric",timeZone:n}).formatToParts(t);return{day:et(a,"day"),month:et(i,"month"),monthIndex:Number(w(et(a,"month"))),year:et(a,"year")}}(T(t),r,o,a);return"bn-BD"===r?{day:b(i.day),month:i.month,monthIndex:i.monthIndex,year:b(i.year)}:{day:Number(w(i.day)),month:i.month,monthIndex:i.monthIndex,year:Number(w(i.year))}}function rt(t){const e=b(t);return 1===t?`${e}লা`:2===t||3===t?`${e}রা`:4===t?`${e}ঠা`:t>=19?`${e}শে`:`${e}ই`}function ot(t){const e=t%100;if(e>=11&&e<=13)return`${t}th`;switch(t%10){case 1:return`${t}st`;case 2:return`${t}nd`;case 3:return`${t}rd`;default:return`${t}th`}}function at(t,e){return"spoken"===(e?.format??"ordinal")?function(t,e="pohela"){switch(t){case 1:return"poyla"===e?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return rt(t)}}(t,e?.variant):rt(t)}function it(t,e){return"2-digit"===e?String(t).padStart(2,"0"):String(t)}function ut(t,e,n){const r=it(t,n);return"bn-BD"===e?b(r):r}function st(t,e,n){if(!e.includes(t))throw new TypeError(`Invalid ${n}: ${t}`)}function dt(t,e,n){if("bn-BD"===e)return t<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=t<12?"AM":"PM";return n?r.toLowerCase():r}function lt(t,e){const n=T(t),r=`${o=n.getFullYear(),o>=0&&o<=9999?String(o).padStart(4,"0"):`${o>=0?"+":"-"}${String(Math.abs(o)).padStart(6,"0")}`}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")} ${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}:${String(n.getSeconds()).padStart(2,"0")}`;var o;return"bn-BD"===e?b(r):r}function ct(t,e){if(void 0!==e&&(null===e||"object"!=typeof e||Array.isArray(e)))throw new TypeError("format() expects an options object");const c=X();if(e&&"pattern"in e&&void 0!==e.pattern){if("mode"in e&&void 0!==e.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const l=e.locale??c.locale;return function(t,e,l="en-BD"){const c=T(t),m="bn-BD"===l,h=c.getDate(),g=c.getMonth(),f=c.getFullYear(),y=m?i:n,b=m?u:r,w=m?s:o,p=m?d:a,$=c.getHours(),D=$%12||12,v={dddd:w[c.getDay()],ddd:p[c.getDay()],MMMM:y[g],MMM:b[g],MM:ut(g+1,l,"2-digit"),M:ut(g+1,l,"numeric"),DD:ut(h,l,"2-digit"),D:ut(h,l,"numeric"),HH:ut($,l,"2-digit"),H:ut($,l,"numeric"),hh:ut(D,l,"2-digit"),h:ut(D,l,"numeric"),mm:ut(c.getMinutes(),l,"2-digit"),m:ut(c.getMinutes(),l,"numeric"),ss:ut(c.getSeconds(),l,"2-digit"),s:ut(c.getSeconds(),l,"numeric"),A:dt($,l,!1),a:dt($,l,!0),YYYY:ut(f,l,"numeric"),YY:ut(Number(String(f).slice(-2)),l,"2-digit")},M=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,S=t=>t.replace(M,t=>v[t]);let j="",N=0;for(;N<e.length;){const t=e.indexOf("[",N);if(-1===t){j+=S(e.slice(N));break}j+=S(e.slice(N,t));const n=e.indexOf("]",t+1);if(-1===n){j+=e.slice(t);break}j+=e.slice(t+1,n),N=n+1}return j}(t,e.pattern,l)}const m=function(t,e){if(void 0===t)return e;if("mode"in t&&void 0!==t.mode)return t.mode;const n=t;return"digits"in n||"monthFormat"in n||"en"===n.month||"bn"===n.month||"en"===n.year||"bn"===n.year||"en"===n.day||"bn"===n.day?"hybrid":"timeZone"in n||"hijriSystem"in n?"hijri":"format"in n||"variant"in n?"bangla":"weekday"in n||"hour"in n||"minute"in n||"second"in n||"hour12"in n||"preset"in n||"short"===n.month||"long"===n.month||"numeric"===n.year||"2-digit"===n.year||"numeric"===n.day||"2-digit"===n.day?"standard":e}(e,c.mode);switch(m){case"standard":return function(t,e){const l=X(),c=e?.locale??l.locale;if("isoLike"===e?.preset)return lt(t,c);const m=function(t){return"dateTime"===t?.preset?{hour:"2-digit",minute:"2-digit",...t}:t??{}}(e),h=T(t),g=m.month??l.month??("bn-BD"===c?"long":"short"),f=m.year??"numeric",y=m.day??"numeric",w=m.weekday,p=m.hour,$=m.minute,D=m.second,v=void 0!==p||void 0!==$||void 0!==D,M="bn-BD"===c;st(g,["short","long"],"month format for standard mode"),st(f,["numeric","2-digit"],"year format for standard mode"),st(y,["numeric","2-digit"],"day format for standard mode"),void 0!==w&&st(w,["short","long"],"weekday format for standard mode"),void 0!==p&&st(p,["numeric","2-digit"],"hour format for standard mode"),void 0!==$&&st($,["numeric","2-digit"],"minute format for standard mode"),void 0!==D&&st(D,["numeric","2-digit"],"second format for standard mode");const S=h.getDate(),j=h.getMonth(),N=h.getFullYear(),Y=M?" খ্রিস্টাব্দ":"",F=`${"2-digit"===y?String(S).padStart(2,"0"):M?rt(S):ot(S)} ${(M?"short"===g?u:i:"short"===g?r:n)[j]} ${"2-digit"===f?String(N).slice(-2):String(N)}${Y}`,k=void 0!==w?`${(M?"short"===w?d:s:"short"===w?a:o)[h.getDay()]}, `:"";let B="";if(v){const t=m.hour12??!1,e=h.getHours(),n=$??(void 0!==D?"2-digit":void 0);B=`${it(t?e%12||12:e,p??"numeric")}${void 0!==n?`:${it(h.getMinutes(),n)}`:""}${void 0!==D?`:${it(h.getSeconds(),D)}`:""}${t?` ${dt(e,c,!1)}`:""}`}const I=`${k}${F}${B?`, ${B}`:""}`;return M?b(I):I}(t,e);case"bangla":return function(t,e){const n=e?.locale??X().locale,r=e?.format??"ordinal",o=e?.variant,a=q(t,{locale:"en-BD"});if("bn-BD"===n){const t=a.monthIndex-1,e={format:r};return void 0!==o&&(e.variant=o),`${at(a.day,e)} ${l[t]} ${b(a.year)} বঙ্গাব্দ`}return`${ot(a.day)} ${a.month} ${a.year}`}(t,e);case"hijri":return function(t,e){const n=e?.locale??X().locale;if("bn-BD"===n){const n=nt(t,{locale:"bn-BD",...void 0!==e?.timeZone&&{timeZone:e.timeZone},...void 0!==e?.hijriSystem&&{hijriSystem:e.hijriSystem}}),r=b(n.year);return`${function(t){const e=b(t);return 1===t?`${e}লা`:2===t?`${e}রা`:`${e}ই`}(Number(w(n.day)))} ${n.month} ${r} হিজরি`}const r=nt(t,{locale:"en-BD",...void 0!==e?.timeZone&&{timeZone:e.timeZone},...void 0!==e?.hijriSystem&&{hijriSystem:e.hijriSystem}});return`${ot(r.day)} ${r.month} ${r.year} AH`}(t,e);case"hybrid":return function(t,e){const o=T(t),a=e?.digits??"en",s=e?.month??"bn",d=e?.year??"en",l=e?.day??a,c=e?.monthFormat??"long";st(a,["en","bn"],"digits language for hybrid mode"),st(s,["en","bn"],"month language for hybrid mode"),st(d,["en","bn"],"year language for hybrid mode"),st(l,["en","bn"],"day language for hybrid mode"),st(c,["short","long"],"month format for hybrid mode");const m=o.getDate(),h=o.getMonth(),g=o.getFullYear(),f="bn"===s?"short"===c?u:i:"short"===c?r:n,y="bn"===l?b(m):String(m),w=f[h],p="bn"===d?b(g):String(g);return`${y} ${w} ${p}`}(t,e);default:throw new TypeError(`Invalid format mode: ${String(m)}`)}}var mt={baishakh:1,boishakh:1,boishak:1,boisakh:1,jaishtho:2,jaishtha:2,jaistha:2,joishtho:2,jyoishtho:2,jyoistho:2,jyeshtho:2,ashar:3,asadh:3,asharh:3,srabon:4,shraban:4,shrabon:4,sraban:4,bhadro:5,ashin:6,ashwin:6,ashshin:6,kartik:7,ograyon:8,ograyan:8,ogrohayon:8,ograhayon:8,agrahayan:8,aghrayan:8,pous:9,poush:9,mag:10,magh:10,falgoon:11,falgun:11,choitra:12,chaitra:12,choitro:12},ht={"বৈশাখ":1,"জ্যৈষ্ঠ":2,"জৈষ্ঠ":2,"আষাঢ়":3,"আষাঢ":3,"শ্রাবণ":4,"ভাদ্র":5,"আশ্বিন":6,"কার্তিক":7,"অগ্রহায়ণ":8,"অগ্রহায়ণ":8,"অঘ্রাণ":8,"অগ্রায়ণ":8,"অগ্রায়ণ":8,"পৌষ":9,"পৌস":9,"মাঘ":10,"ফাল্গুন":11,"চৈত্র":12},gt=/^([+-]\d{6}|\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/,ft=/^([+-]\d{6}|\d{4})([-/.])(\d{2})\2(\d{2})$/,yt=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/,bt=/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4}|\d{2})$/i,wt=/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4})$/i,pt=/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4}|\d{2})$/i,$t=/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4})$/i;function Dt(t){const e=t.toLowerCase();for(let e=0;e<l.length;e+=1)if(l[e]===t)return e+1;const n=ht[t];if(void 0!==n)return n;for(let t=0;t<c.length;t+=1)if(c[t].toLowerCase()===e)return t+1;const r=mt[e];return void 0!==r?r:-1}function vt(t){const e=t.trim(),o=e.toLowerCase();for(let t=0;t<n.length;t+=1)if(n[t].toLowerCase()===o)return t;for(let t=0;t<r.length;t+=1)if(r[t].toLowerCase()===o)return t;for(let t=0;t<i.length;t+=1)if(i[t]===e)return t;for(let t=0;t<u.length;t+=1)if(u[t]===e)return t;return-1}function Mt(t,e,n,r,o,a){return{success:!0,input:t,normalizedInput:e,calendar:n,strict:r,format:o,date:a}}function St(t,e,n,r,o,a){return{success:!1,input:t,normalizedInput:e,calendar:n,strict:r,reason:o,message:a,date:null}}function jt(t){if(gt.test(t))return"ymd";if(yt.test(t))return"iso_datetime";const e=t.match(bt);if(e&&-1!==$(e[2].replace(/,$/,"")))return"day_month_year";const n=t.match(pt);return n&&-1!==$(n[1].replace(/,$/,""))?"month_day_year":null}function Nt(t,e,n){const r=n?function(t){if(ft.test(t))return"ymd";if(yt.test(t))return"iso_datetime";const e=t.match(wt);if(e&&-1!==vt(e[2].replace(/,$/,"")))return"day_month_year";const n=t.match($t);return n&&-1!==vt(n[1].replace(/,$/,""))?"month_day_year":null}(e):jt(e);if(null===r){if(n){if(null!==jt(e)&&null!==j(e))return St(t,e,"gregorian",!0,"strict_mismatch","Input matches a supported loose Gregorian format but fails strict parsing.")}return St(t,e,"gregorian",n,"invalid_string","Input does not match a supported Gregorian date format.")}const o=j(e);return null===o?St(t,e,"gregorian",n,"invalid_string","Input matches a Gregorian date shape but is not a valid calendar date."):Mt(t,e,"gregorian",n,r,o)}function Tt(t,e,n){const r=e.match(/^(\S+),?\s+(\S+),?\s+(\d+)$/);if(!r)return St(t,e,"bangla",n,"invalid_string","Input does not match a supported Bangla calendar date format.");const o=function(t){const e={"পহেলা":1,"পয়লা":1,"পয়লা":1,"দোসরা":2,"তেসরা":3,"চৌঠা":4}[t];if(void 0!==e)return e;const n=t.match(/^(\d{1,2})(?:লা|রা|ঠা|ই|শে)$/);if(n)return Number(n[1]);const r=t.match(/^(\d{1,2})(?:st|nd|rd|th)$/i);if(r)return Number(r[1]);const o=Number(t);return Number.isInteger(o)&&o>=1&&o<=31?o:null}(r[1].replace(/,$/,""));if(null===o)return St(t,e,"bangla",n,"invalid_string","Bangla calendar day is invalid.");const a=r[2].replace(/,$/,""),i=n?function(t){for(let e=0;e<l.length;e+=1)if(l[e]===t)return e+1;const e=t.toLowerCase();for(let t=0;t<c.length;t+=1)if(c[t].toLowerCase()===e)return t+1;return-1}(a):Dt(a);if(-1===i)return n?-1!==Dt(a)?St(t,e,"bangla",!0,"strict_mismatch","Input uses a legacy Bangla month alias that is rejected in strict mode."):St(t,e,"bangla",!0,"invalid_string","Bangla calendar month is invalid."):St(t,e,"bangla",!1,"invalid_string","Bangla calendar month is invalid.");const u=Number(r[3]);try{return Mt(t,e,"bangla",n,"bangla_calendar",z(o,i,u))}catch(r){return St(t,e,"bangla",n,"invalid_bangla_calendar_date",r instanceof Error?r.message:"Bangla calendar date is invalid.")}}function Yt(t,e){const n=e?.calendar??"gregorian",r=e?.strict??!1;if(t instanceof Date)return Number.isNaN(t.getTime())?St(t,null,n,r,"invalid_date_object","Date object is invalid."):Mt(t,null,n,r,"date_object",new Date(t.getTime()));if("number"==typeof t){if(!Number.isFinite(t))return St(t,t,n,r,"invalid_timestamp","Timestamp is invalid.");const e=new Date(t);if(Number.isNaN(e.getTime())){const e=Math.abs(t)>864e13;return St(t,t,n,r,e?"out_of_range":"invalid_timestamp",e?"Timestamp is outside the supported Date range.":"Timestamp is invalid.")}return Mt(t,t,n,r,"timestamp",e)}const o=w(t).trim();return 0===o.length?St(t,o,n,r,"invalid_string","Input is empty."):"bangla"===n?Tt(t,o,r):Nt(t,o,r)}function Ft(t,e){const n=Yt(t,e);return n.success?n.date:null}var kt=1e3,Bt=36e5,It=24*Bt,Ct={second:"s",seconds:"s",minute:"m",minutes:"m",hour:"h",hours:"h",day:"d",days:"d",week:"wk",weeks:"wk",month:"mo",months:"mo",year:"y",years:"y",ago:"ago",in:"in",justNow:"now"},_t={second:"সে.",seconds:"সে.",minute:"মি.",minutes:"মি.",hour:"ঘ.",hours:"ঘ.",day:"দিন",days:"দিন",week:"সপ্তা.",weeks:"সপ্তা.",month:"মাস",months:"মাস",year:"বছ.",years:"বছ.",ago:"আগে",in:"",justNow:"এখন"},Ht={justNow:kt,minute:6e4,hour:Bt,day:It,week:7*It,month:30*It,year:365*It};function Et(t,e){return new Date(t,e+1,0).getDate()}function Ut(t,e){let n=t.getFullYear()-e.getFullYear();const r=function(t,e){const n=t.getFullYear()+e,r=t.getMonth(),o=Math.min(t.getDate(),Et(n,r));return new Date(n,r,o,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function Zt(t,e){let n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth());const r=function(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=n+Math.floor(r/12),a=(r%12+12)%12,i=Math.min(t.getDate(),Et(o,a));return new Date(o,a,i,t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}(e,n);return r>t&&(n-=1),n}function xt(t,e){if(!Number.isFinite(t)||t<0)throw new RangeError(`Invalid relative time threshold for ${e}: ${t}`)}function At(t,e,n,r,o,a){const i="bn-BD"===o,u=i?b(t):String(t),s=1===t?e:n,d="short"===a&&"en-BD"===o?`${u}${s}`:`${u} ${s}`;return i?r?`${d} আগে`:`${d} পরে`:r?`${d} ago`:`in ${d}`}function Lt(t,e,n){return"bn-BD"===n?"day"===t?e?"গতকাল":"আগামীকাল":"week"===t?e?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===t?e?"গত মাসে":"আগামী মাসে":e?"গত বছর":"আগামী বছর":"day"===t?e?"yesterday":"tomorrow":"week"===t?e?"last week":"next week":"month"===t?e?"last month":"next month":e?"last year":"next year"}function Ot(t,e){const n=X(),r=T(t),o=e?.locale??n.locale,a=e?.numeric??"always",i=e?.style??"long",u=function(t){const e={...Ht,...t};xt(e.justNow,"justNow"),xt(e.minute,"minute"),xt(e.hour,"hour"),xt(e.day,"day"),xt(e.week,"week"),xt(e.month,"month"),xt(e.year,"year");const n=[e.justNow,e.minute,e.hour,e.day,e.week,e.month,e.year];for(let t=1;t<n.length;t+=1)if(n[t]<n[t-1])throw new RangeError("Relative time thresholds must be non-decreasing from justNow to year");return e}(e?.threshold),s=void 0===e?.baseDate?new Date:T(e.baseDate),d=function(t,e){return"short"===e?"bn-BD"===t?_t:Ct:"bn-BD"===t?y:f}(o,i),l=s.getTime()-r.getTime(),c=Math.abs(l),m=l>0,h=m?s:r,g=m?r:s;if(c<u.justNow)return d.justNow;if("auto"===a&&(w=s,(b=r).getFullYear()===w.getFullYear()&&b.getMonth()===w.getMonth()&&b.getDate()===w.getDate()))return function(t){return"bn-BD"===t?"আজ":"today"}(o);var b,w;const p=Ut(h,g);if(p>=1&&c>=u.year){if("auto"===a&&1===p){const t=Lt("year",m,o);if(null!==t)return t}return At(p,d.year,d.years,m,o,i)}const $=Zt(h,g);if($>=1&&c>=u.month){if("auto"===a&&1===$){const t=Lt("month",m,o);if(null!==t)return t}return At($,d.month,d.months,m,o,i)}const D=[{threshold:u.week,singular:"week",plural:"weeks"},{threshold:u.day,singular:"day",plural:"days"},{threshold:u.hour,singular:"hour",plural:"hours"},{threshold:u.minute,singular:"minute",plural:"minutes"},{threshold:kt,singular:"second",plural:"seconds"}];for(const t of D)if(c>=t.threshold){const e=Math.floor(c/t.threshold);if("auto"===a&&1===e&&("day"===t.singular||"week"===t.singular)){const e=Lt(t.singular,m,o);if(null!==e)return e}return At(e,d[t.singular],d[t.plural],m,o,i)}return d.justNow}export{l as BANGLA_CALENDAR_MONTHS,c as BANGLA_CALENDAR_MONTHS_EN,m as BANGLA_CALENDAR_MONTH_DAYS,e as BANGLA_DIGITS,i as BANGLA_MONTHS_FULL,u as BANGLA_MONTHS_SHORT,s as BANGLA_WEEKDAYS_FULL,d as BANGLA_WEEKDAYS_SHORT,g as BOISHAKH_START_DAY,h as BOISHAKH_START_MONTH,t as ENGLISH_DIGITS,n as ENGLISH_MONTHS_FULL,r as ENGLISH_MONTHS_SHORT,o as ENGLISH_WEEKDAYS_FULL,a as ENGLISH_WEEKDAYS_SHORT,P as HIJRI_TIME_ZONES,y as RELATIVE_TIME_BN,f as RELATIVE_TIME_EN,C as addDays,E as addMonths,Z as addYears,I as endOfDay,L as endOfMonth,J as endOfYear,ct as format,at as formatBanglaCalendarDay,z as fromBanglaCalendar,Ot as fromNow,R as getBanglaMonth,X as getDefaults,Y as isToday,k as isTomorrow,F as isYesterday,Ft as parseDate,Yt as parseDateDetailed,tt as setDefaults,B as startOfDay,A as startOfMonth,O as startOfYear,_ as subDays,U as subMonths,x as subYears,q as toBanglaCalendar,b as toBanglaDigits,T as toDate,w as toEnglishDigits,nt as toHijriCalendar};
|