@coreify/tarikh 1.0.0 → 1.0.2

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/dist/react.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{forwardRef as e,createElement as t}from"react";var n=["0","1","2","3","4","5","6","7","8","9"],r=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],a=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],u=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],s=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],c=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],d=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],g=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],h=["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],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(e){return String(e).replace(/\d/g,e=>r[Number(e)]??e)}function v(e){return String(e).replace(/[০-৯]/g,e=>{const t=r.indexOf(e);return t>=0?n[t]??e:e})}var w={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 $(e){const t=e.trim(),n=t.toLowerCase(),r=w[n];if(void 0!==r)return r;for(let e=0;e<a.length;e++)if(a[e].toLowerCase()===n)return e;for(let e=0;e<o.length;e++)if(o[e].toLowerCase()===n)return e;for(let e=0;e<l.length;e++)if(l[e]===t)return e;for(let e=0;e<s.length;e++)if(s[e]===t)return e;return-1}function D(e,t,n,r=0,a=0,o=0,u=0){const i=new Date(e,t,n,r,a,o,u);return i.getFullYear()!==e||i.getMonth()!==t||i.getDate()!==n||i.getHours()!==r||i.getMinutes()!==a||i.getSeconds()!==o||i.getMilliseconds()!==u?null:i}function p(e){return function(e){const t=e.trim().match(/^(\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return t?D(Number(t[1]),Number(t[3])-1,Number(t[4])):null}(e)??function(e){const t=e.trim().match(/^(\d{4})-(\d{2})-(\d{2})(?:[T\s](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:?\d{2})?)$/);if(!t)return null;const n=Number(t[1]),r=Number(t[2]),a=Number(t[3]),o=Number(t[4]??0),u=Number(t[5]??0),i=Number(t[6]??0),l=Number((t[7]??"0").padEnd(3,"0").slice(0,3)),s=t[8];if(void 0===s)return D(n,r-1,a,o,u,i,l);const c=s.match(/^([+-])(\d{2}):?(\d{2})$/),d="Z"===s?0:c?("+"===c[1]?1:-1)*(60*Number(c[2])+Number(c[3])):null;if(null===d)return null;const g=Date.UTC(n,r-1,a,o,u,i,l)-6e4*d,h=new Date(g),m=new Date(g+6e4*d);return m.getUTCFullYear()!==n||m.getUTCMonth()!==r-1||m.getUTCDate()!==a||m.getUTCHours()!==o||m.getUTCMinutes()!==u||m.getUTCSeconds()!==i||m.getUTCMilliseconds()!==l?null:h}(e)??function(e){const t=e.match(/^(\d{1,2})(?:st|nd|rd|th)?(?:\s+|-)(\S+)(?:\s+|-)(\d{2,4})$/);if(!t)return null;const n=Number(t[1]),r=t[2].replace(/,$/,""),a=t[3],o=$(r);if(-1===o)return null;let u=Number(a);return 2===a.length&&(u+=u>=50?1900:2e3),D(u,o,n)}(e)??function(e){const t=e.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th)?(?:,)?\s+(\d{2,4})$/);if(!t)return null;const n=t[1].replace(/,$/,""),r=Number(t[2]),a=t[3],o=$(n);if(-1===o)return null;let u=Number(a);return 2===a.length&&(u+=u>=50?1900:2e3),D(u,o,r)}(e)}function N(e){if(e instanceof Date){const t=e.getTime();if(Number.isNaN(t))throw new Error(`Invalid date input: ${String(e)}`);return new Date(t)}if("number"==typeof e){if(!Number.isFinite(e))throw new Error(`Invalid date input: ${String(e)}`);const t=new Date(e);if(Number.isNaN(t.getTime()))throw new Error(`Invalid date input: ${String(e)}`);return t}const t=p(v(e).trim());if(!t)throw new Error(`Invalid date input: ${String(e)}`);return t}function M(e,t){const n=N(e),r=n.getFullYear(),a=n.getMonth(),o=n.getDate(),u=new Date(r,3,14),i=a<3||3===a&&o<14,l=i?r-594:r-593,s=function(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)}(i?new Date(r-1,3,14):u,n)+1,c=function(e){const t=[...m];return function(e){return(t=e+594)%4==0&&t%100!=0||t%400==0;var t}(e)&&(t[10]=31),t}(l);let d=s,g=0;for(let e=0;e<c.length;e++){const t=c[e];if(d<=t){g=e;break}d-=t}return{day:d,month:h[g],monthIndex:g+1,year:l}}function S(e){const t=b(e);return 1===e?`${t}লা`:2===e||3===e?`${t}রা`:4===e?`${t}ঠা`:e>=19?`${t}শে`:`${t}ই`}function T(e,t){return"spoken"===(t?.format??"ordinal")?function(e,t="pohela"){switch(e){case 1:return"poyla"===t?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return S(e)}}(e,t?.variant):S(e)}function k(e,t){return"2-digit"===t?String(e).padStart(2,"0"):String(e)}var F=1e3,j=36e5,C=24*j,Y=[{threshold:7*C,singular:"week",plural:"weeks"},{threshold:C,singular:"day",plural:"days"},{threshold:j,singular:"hour",plural:"hours"},{threshold:6e4,singular:"minute",plural:"minutes"},{threshold:F,singular:"second",plural:"seconds"}];function B(e,t){return new Date(e,t+1,0).getDate()}function U(e,t){let n=e.getFullYear()-t.getFullYear();const r=function(e,t){const n=e.getFullYear()+t,r=e.getMonth(),a=Math.min(e.getDate(),B(n,r));return new Date(n,r,a,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function A(e,t){let n=12*(e.getFullYear()-t.getFullYear())+(e.getMonth()-t.getMonth());const r=function(e,t){const n=e.getFullYear(),r=e.getMonth()+t,a=n+Math.floor(r/12),o=(r%12+12)%12,u=Math.min(e.getDate(),B(a,o));return new Date(a,o,u,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function x(e,t,n,r,a){const o="bn-BD"===a,u=o?b(e):String(e),i=1===e?t:n;return o?r?`${u} ${i} আগে`:`${u} ${i} পরে`:r?`${u} ${i} ago`:`in ${u} ${i}`}function I(e,t,n){return"bn-BD"===n?"day"===e?t?"গতকাল":"আগামীকাল":"week"===e?t?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===e?t?"গত মাসে":"আগামী মাসে":t?"গত বছর":"আগামী বছর":"day"===e?t?"yesterday":"tomorrow":"week"===e?t?"last week":"next week":"month"===e?t?"last month":"next month":t?"last year":"next year"}function J(e){return"string"==typeof e&&!/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?(?:Z|[+-]\d{2}:?\d{2})?$/i.test(e.trim())&&null!==function(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getTime());if("number"==typeof e){const t=new Date(e);return Number.isNaN(t.getTime())?null:t}return p(v(e).trim())}(e)}function L(e,t){return J(e)?function(e){return`${String(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}(t):t.toISOString()}var O=e(function({value:e,locale:n,month:r,year:g,day:h,weekday:m,hour:f,minute:y,second:v,hour12:w,srLabel:$,"aria-label":D,...p},M){const S=N(e),T=function(e,t){const n=N(e),r=t?.locale??"en-BD",g=t?.month??"short",h=t?.year??"numeric",m=t?.day??"numeric",f=t?.weekday,y=t?.hour,v=t?.minute,w=t?.second,$=void 0!==y||void 0!==v||void 0!==w,D="bn-BD"===r,p=n.getDate(),M=n.getMonth(),S=n.getFullYear(),T=`${"2-digit"===m?String(p).padStart(2,"0"):String(p)} ${(D?"short"===g?s:l:"short"===g?o:a)[M]} ${"2-digit"===h?String(S).slice(-2):String(S)}`,F=void 0!==f?`${(D?"short"===f?d:c:"short"===f?i:u)[n.getDay()]}, `:"";let j="";if($){const e=t?.hour12??!1,a=n.getHours(),o=v??(void 0!==w?"2-digit":void 0),u=k(e?a%12||12:a,y??"numeric"),i=void 0!==o?`:${k(n.getMinutes(),o)}`:"",l=void 0!==w?`:${k(n.getSeconds(),w)}`:"",s=e?` ${function(e,t){if("bn-BD"===t)return e<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const n=e<12?"AM":"PM";return!1?n.toLowerCase():n}(a,r)}`:"";j=`${u}${i}${l}${s}`}const C=`${F}${T}${j?`, ${j}`:""}`;return D?b(C):C}(S,{...void 0!==n&&{locale:n},...void 0!==r&&{month:r},...void 0!==g&&{year:g},...void 0!==h&&{day:h},...void 0!==m&&{weekday:m},...void 0!==f&&{hour:f},...void 0!==y&&{minute:y},...void 0!==v&&{second:v},...void 0!==w&&{hour12:w}}),F=L(e,S);return t("time",{...p,ref:M,dateTime:F,"aria-label":$??D??T},T)});O.displayName="Tarikh";var E=e(function({value:e,locale:n,numeric:r,srLabel:a,"aria-label":o,...u},i){const l=N(e),s={...void 0!==n&&{locale:n},...void 0!==r&&{numeric:r}},c=function(e,t){const n=N(e),r=t?.locale??"en-BD",a=t?.numeric??"always",o="bn-BD"===r?y:f,u=Date.now()-n.getTime(),i=Math.abs(u),l=u>0,s=new Date,c=n.getFullYear()===s.getFullYear()&&n.getMonth()===s.getMonth()&&n.getDate()===s.getDate(),d=l?s:n,g=l?n:s;if(i<F)return o.justNow;if("auto"===a&&c)return function(e){return"bn-BD"===e?"আজ":"today"}(r);const h=U(d,g);if(h>=1){if("auto"===a&&1===h){const e=I("year",l,r);if(null!==e)return e}return x(h,o.year,o.years,l,r)}const m=A(d,g);if(m>=1){if("auto"===a&&1===m){const e=I("month",l,r);if(null!==e)return e}return x(m,o.month,o.months,l,r)}for(const e of Y)if(i>=e.threshold){const t=Math.floor(i/e.threshold);if("auto"===a&&1===t&&("day"===e.singular||"week"===e.singular)){const t=I(e.singular,l,r);if(null!==t)return t}return x(t,o[e.singular],o[e.plural],l,r)}return o.justNow}(l,Object.keys(s).length>0?s:void 0),d=L(e,l);return t("time",{...u,ref:i,dateTime:d,"aria-label":a??o??c},c)});E.displayName="RelativeTime";var H=e(function({value:e,locale:n,format:r,variant:a,srLabel:o,"aria-label":u,...i},l){const s=N(e),c={...void 0!==n&&{locale:n},...void 0!==r&&{format:r},...void 0!==a&&{variant:a}},d=function(e,t){const n=t?.locale??"en-BD",r=t?.format??"ordinal",a=t?.variant,o=M(e);if("bn-BD"===n){const e=o.monthIndex-1,t={format:r};return void 0!==a&&(t.variant=a),`${T(o.day,t)} ${g[e]} ${b(o.year)}`}return`${o.day} ${o.month} ${o.year}`}(s,Object.keys(c).length>0?c:void 0),h=L(e,s);return t("time",{...i,ref:l,dateTime:h,"aria-label":o??u??d},d)});H.displayName="BanglaDate";export{H as BanglaDate,E as RelativeTime,O as Tarikh};
2
+ import{forwardRef as e,createElement as t}from"react";var n=["0","1","2","3","4","5","6","7","8","9"],r=["০","১","২","৩","৪","৫","৬","৭","৮","৯"],o=["January","February","March","April","May","June","July","August","September","October","November","December"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],u=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=["জানুয়ারি","ফেব্রুয়ারি","মার্চ","এপ্রিল","মে","জুন","জুলাই","আগস্ট","সেপ্টেম্বর","অক্টোবর","নভেম্বর","ডিসেম্বর"],d=["জানু","ফেব্রু","মার্চ","এপ্রি","মে","জুন","জুলা","আগ","সেপ্টে","অক্টো","নভে","ডিসে"],l=["রবিবার","সোমবার","মঙ্গলবার","বুধবার","বৃহস্পতিবার","শুক্রবার","শনিবার"],c=["রবি","সোম","মঙ্গল","বুধ","বৃহস্পতি","শুক্র","শনি"],m=["বৈশাখ","জ্যৈষ্ঠ","আষাঢ়","শ্রাবণ","ভাদ্র","আশ্বিন","কার্তিক","অগ্রহায়ণ","পৌষ","মাঘ","ফাল্গুন","চৈত্র"],g=["Baishakh","Jaishtho","Asharh","Shrabon","Bhadro","Ashshin","Kartik","Agrahayan","Poush","Magh","Falgun","Chaitra"],h=[31,31,31,31,31,30,30,30,30,30,30,30],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(e){return String(e).replace(/\d/g,e=>r[Number(e)]??e)}function $(e){return String(e).replace(/[০-৯]/g,e=>{const t=r.indexOf(e);return t>=0?n[t]??e:e})}var w={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(e){const t=e.trim(),n=t.toLowerCase(),r=w[n];if(void 0!==r)return r;for(let e=0;e<o.length;e++)if(o[e].toLowerCase()===n)return e;for(let e=0;e<a.length;e++)if(a[e].toLowerCase()===n)return e;for(let e=0;e<s.length;e++)if(s[e]===t)return e;for(let e=0;e<d.length;e++)if(d[e]===t)return e;return-1}function v(e){return Number.isFinite(e)&&Math.abs(e)<=864e13}function D(e,t,n,r=0,o=0,a=0,i=0){const u=new Date(0);return u.setUTCFullYear(e,t,n),u.setUTCHours(r,o,a,i),u.getUTCFullYear()!==e||u.getUTCMonth()!==t||u.getUTCDate()!==n||u.getUTCHours()!==r||u.getUTCMinutes()!==o||u.getUTCSeconds()!==a||u.getUTCMilliseconds()!==i?null:u}function M(e,t,n,r=0,o=0,a=0,i=0){return function(e,t,n,r=0,o=0,a=0,i=0){const u=new Date(0);return u.setFullYear(e,t,n),u.setHours(r,o,a,i),u.getFullYear()!==e||u.getMonth()!==t||u.getDate()!==n||u.getHours()!==r||u.getMinutes()!==o||u.getSeconds()!==a||u.getMilliseconds()!==i?null:u}(e,t,n,r,o,a,i)??D(e,t,n,r,o,a,i)}function T(e){if(!/^[+-]?\d+$/.test(e))return null;const t=Number(e);return Number.isInteger(t)?t:null}function N(e){return function(e){const t=e.trim().match(/^([+-]\d{6}|\d{4})([-/.])(\d{1,2})\2(\d{1,2})$/);return t?M(Number(t[1]),Number(t[3])-1,Number(t[4])):null}(e)??function(e){const t=e.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(!t)return null;const n=Number(t[1]),r=Number(t[2]),o=Number(t[3]),a=Number(t[4]??0),i=Number(t[5]??0),u=Number(t[6]??0),s=Number((t[7]??"0").padEnd(3,"0").slice(0,3)),d=t[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,g="Z"===d?0:l&&null!==c&&null!==m&&c<=23&&m<=59?("+"===l[1]?1:-1)*(60*c+m):null;if(null===g)return null;const h=D(n,r-1,o,a,i,u,s);if(!h)return null;const f=h.getTime()-6e4*g;if(!v(f))return null;const y=new Date(f),b=new Date(f+6e4*g);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}(e)??function(e){const t=e.match(/^(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:\s+|-)(\S+)(?:\s+|-)([+-]\d{6}|\d{4}|\d{2})$/);if(!t)return null;const n=Number(t[1]),r=t[2].replace(/,$/,""),o=t[3],a=p(r);if(-1===a)return null;const i=T(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)}(e)??function(e){const t=e.match(/^(\S+)\s+(\d{1,2})(?:st|nd|rd|th|লা|রা|ঠা|ই|শে)?(?:,)?\s+([+-]\d{6}|\d{4}|\d{2})$/);if(!t)return null;const n=t[1].replace(/,$/,""),r=Number(t[2]),o=t[3],a=p(n);if(-1===a)return null;const i=T(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)}(e)}function S(e,t,n){if(!v(e.getTime())){throw new RangeError(`${"Date input"} is outside the supported range: ${String(t)}`)}return e}function Y(e){if(e instanceof Date){const t=e.getTime();if(Number.isNaN(t))throw new Error(`Invalid date input: ${String(e)}`);return S(new Date(t),e)}if("number"==typeof e){if(!Number.isFinite(e))throw new Error(`Invalid date input: ${String(e)}`);const t=new Date(e);if(Number.isNaN(t.getTime())){if(!v(e))throw new RangeError(`Date input is outside the supported range: ${String(e)}`);throw new Error(`Invalid date input: ${String(e)}`)}return S(t,e)}const t=N($(e).trim());if(!t)throw new Error(`Invalid date input: ${String(e)}`);return S(t,e)}function F(e,t){const n=Y(e),r=n.getFullYear(),o=n.getMonth(),a=n.getDate(),i=new Date(r,3,14),u=o<3||3===o&&a<14,s=u?r-594:r-593,d=function(e,t){const n=Date.UTC(e.getFullYear(),e.getMonth(),e.getDate()),r=Date.UTC(t.getFullYear(),t.getMonth(),t.getDate());return Math.floor((r-n)/864e5)}(u?new Date(r-1,3,14):i,n)+1,l=function(e){const t=[...h];return function(e){return(t=e+594)%4==0&&t%100!=0||t%400==0;var t}(e)&&(t[10]=31),t}(s);let c=d,m=0;for(let e=0;e<l.length;e++){const t=l[e];if(c<=t){m=e;break}c-=t}return{day:c,month:g[m],monthIndex:m+1,year:s}}var j=["Asia/Dhaka","UTC"];function k(e,t){const n=e.find(e=>e.type===t);if(void 0===n)throw new Error(`Missing ${t} part while formatting Hijri date.`);return n.value}function C(e,t){const n=t?.locale??"en-BD",r=t?.timeZone??"Asia/Dhaka";!function(e){if(!j.includes(e))throw new RangeError(`Unsupported Hijri time zone: ${e}. Supported values: ${j.join(", ")}`)}(r);const o=function(e,t,n){const r=function(e){return`${e}-u-ca-islamic-umalqura`}(t),o=new Intl.DateTimeFormat(r,{day:"numeric",month:"numeric",year:"numeric",timeZone:n}).formatToParts(e),a=new Intl.DateTimeFormat(r,{day:"numeric",month:"long",year:"numeric",timeZone:n}).formatToParts(e);return{day:k(o,"day"),month:k(a,"month"),monthIndex:Number($(k(o,"month"))),year:k(o,"year")}}(Y(e),n,r);return"bn-BD"===n?{day:b(o.day),month:o.month,monthIndex:o.monthIndex,year:b(o.year)}:{day:Number($(o.day)),month:o.month,monthIndex:o.monthIndex,year:Number($(o.year))}}function B(e){const t=b(e);return 1===e?`${t}লা`:2===e||3===e?`${t}রা`:4===e?`${t}ঠা`:e>=19?`${t}শে`:`${t}ই`}function H(e){const t=e%100;if(t>=11&&t<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function U(e,t){return"spoken"===(t?.format??"ordinal")?function(e,t="pohela"){switch(e){case 1:return"poyla"===t?"পয়লা":"পহেলা";case 2:return"দোসরা";case 3:return"তেসরা";case 4:return"চৌঠা";default:return B(e)}}(e,t?.variant):B(e)}function I(e,t){return"2-digit"===t?String(e).padStart(2,"0"):String(e)}function x(e,t,n){const r=I(e,n);return"bn-BD"===t?b(r):r}function A(e,t,n){if(!t.includes(e))throw new TypeError(`Invalid ${n}: ${e}`)}function E(e,t,n){if("bn-BD"===t)return e<12?"পূর্বাহ্ণ":"অপরাহ্ণ";const r=e<12?"AM":"PM";return n?r.toLowerCase():r}function Z(e,t){if(null===t||"object"!=typeof t||Array.isArray(t))throw new TypeError("format() expects an options object");if("pattern"in t&&void 0!==t.pattern){if("mode"in t&&void 0!==t.mode)throw new TypeError("Do not pass `mode` when `pattern` is provided. `pattern` formatting does not use mode.");const n="locale"in t&&void 0!==t.locale?t.locale:"en-BD";return function(e,t,n="en-BD"){const r=Y(e),m="bn-BD"===n,g=r.getDate(),h=r.getMonth(),f=r.getFullYear(),y=m?s:o,b=m?d:a,$=m?l:i,w=m?c:u,p=r.getHours(),v=p%12||12,D={dddd:$[r.getDay()],ddd:w[r.getDay()],MMMM:y[h],MMM:b[h],MM:x(h+1,n,"2-digit"),M:x(h+1,n,"numeric"),DD:x(g,n,"2-digit"),D:x(g,n,"numeric"),HH:x(p,n,"2-digit"),H:x(p,n,"numeric"),hh:x(v,n,"2-digit"),h:x(v,n,"numeric"),mm:x(r.getMinutes(),n,"2-digit"),m:x(r.getMinutes(),n,"numeric"),ss:x(r.getSeconds(),n,"2-digit"),s:x(r.getSeconds(),n,"numeric"),A:E(p,n,!1),a:E(p,n,!0),YYYY:x(f,n,"numeric"),YY:x(Number(String(f).slice(-2)),n,"2-digit")},M=/dddd|ddd|MMMM|MMM|MM|M|DD|D|YYYY|YY|HH|H|hh|h|mm|m|ss|s|A|a/g,T=e=>e.replace(M,e=>D[e]);let N="",S=0;for(;S<t.length;){const e=t.indexOf("[",S);if(-1===e){N+=T(t.slice(S));break}N+=T(t.slice(S,e));const n=t.indexOf("]",e+1);if(-1===n){N+=t.slice(e);break}N+=t.slice(e+1,n),S=n+1}return N}(e,t.pattern,n)}if(!("mode"in t)||void 0===t.mode)throw new TypeError("format() expects `mode` or `pattern`");const n=t.mode;switch(n){case"standard":return function(e,t){const n=Y(e),r=t?.locale??"en-BD",m=t?.month??"short",g=t?.year??"numeric",h=t?.day??"numeric",f=t?.weekday,y=t?.hour,$=t?.minute,w=t?.second,p=void 0!==y||void 0!==$||void 0!==w,v="bn-BD"===r;A(m,["short","long"],"month format for standard mode"),A(g,["numeric","2-digit"],"year format for standard mode"),A(h,["numeric","2-digit"],"day format for standard mode"),void 0!==f&&A(f,["short","long"],"weekday format for standard mode"),void 0!==y&&A(y,["numeric","2-digit"],"hour format for standard mode"),void 0!==$&&A($,["numeric","2-digit"],"minute format for standard mode"),void 0!==w&&A(w,["numeric","2-digit"],"second format for standard mode");const D=n.getDate(),M=n.getMonth(),T=n.getFullYear(),N=v?" খ্রিস্টাব্দ":"",S=`${"2-digit"===h?String(D).padStart(2,"0"):v?B(D):H(D)} ${(v?"short"===m?d:s:"short"===m?a:o)[M]} ${"2-digit"===g?String(T).slice(-2):String(T)}${N}`,F=void 0!==f?`${(v?"short"===f?c:l:"short"===f?u:i)[n.getDay()]}, `:"";let j="";if(p){const e=t?.hour12??!1,o=n.getHours(),a=$??(void 0!==w?"2-digit":void 0);j=`${I(e?o%12||12:o,y??"numeric")}${void 0!==a?`:${I(n.getMinutes(),a)}`:""}${void 0!==w?`:${I(n.getSeconds(),w)}`:""}${e?` ${E(o,r,!1)}`:""}`}const k=`${F}${S}${j?`, ${j}`:""}`;return v?b(k):k}(e,t);case"bangla":return function(e,t){const n=t?.locale??"en-BD",r=t?.format??"ordinal",o=t?.variant,a=F(e);if("bn-BD"===n){const e=a.monthIndex-1,t={format:r};return void 0!==o&&(t.variant=o),`${U(a.day,t)} ${m[e]} ${b(a.year)} বঙ্গাব্দ`}return`${H(a.day)} ${a.month} ${a.year}`}(e,t);case"hijri":return function(e,t){const n=t?.locale??"en-BD",r=t?.timeZone;if("bn-BD"===n){const t={locale:n};void 0!==r&&(t.timeZone=r);const o=C(e,t),a=b(o.year);return`${function(e){const t=b(e);return 1===e?`${t}লা`:2===e?`${t}রা`:`${t}ই`}(Number($(o.day)))} ${o.month} ${a} হিজরি`}const o={locale:n};void 0!==r&&(o.timeZone=r);const a=C(e,o);return`${H(a.day)} ${a.month} ${a.year} AH`}(e,t);case"hybrid":return function(e,t){const n=Y(e),r=t?.digits??"en",i=t?.month??"bn",u=t?.year??"en",l=t?.day??r,c=t?.monthFormat??"long";A(r,["en","bn"],"digits language for hybrid mode"),A(i,["en","bn"],"month language for hybrid mode"),A(u,["en","bn"],"year language for hybrid mode"),A(l,["en","bn"],"day language for hybrid mode"),A(c,["short","long"],"month format for hybrid mode");const m=n.getDate(),g=n.getMonth(),h=n.getFullYear(),f="bn"===i?"short"===c?d:s:"short"===c?a:o,y="bn"===l?b(m):String(m),$=f[g],w="bn"===u?b(h):String(h);return`${y} ${$} ${w}`}(e,t);default:throw new TypeError(`Invalid format mode: ${String(n)}`)}}var L=1e3,J=36e5,O=24*J,W=[{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:L,singular:"second",plural:"seconds"}];function R(e,t){return new Date(e,t+1,0).getDate()}function P(e,t){let n=e.getFullYear()-t.getFullYear();const r=function(e,t){const n=e.getFullYear()+t,r=e.getMonth(),o=Math.min(e.getDate(),R(n,r));return new Date(n,r,o,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function q(e,t){let n=12*(e.getFullYear()-t.getFullYear())+(e.getMonth()-t.getMonth());const r=function(e,t){const n=e.getFullYear(),r=e.getMonth()+t,o=n+Math.floor(r/12),a=(r%12+12)%12,i=Math.min(e.getDate(),R(o,a));return new Date(o,a,i,e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds())}(t,n);return r>e&&(n-=1),n}function z(e,t,n,r,o){const a="bn-BD"===o,i=a?b(e):String(e),u=1===e?t:n;return a?r?`${i} ${u} আগে`:`${i} ${u} পরে`:r?`${i} ${u} ago`:`in ${i} ${u}`}function K(e,t,n){return"bn-BD"===n?"day"===e?t?"গতকাল":"আগামীকাল":"week"===e?t?"গত সপ্তাহে":"আগামী সপ্তাহে":"month"===e?t?"গত মাসে":"আগামী মাসে":t?"গত বছর":"আগামী বছর":"day"===e?t?"yesterday":"tomorrow":"week"===e?t?"last week":"next week":"month"===e?t?"last month":"next month":t?"last year":"next year"}function G(e){return"string"==typeof e&&!/(?:T|\s)\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?$/i.test(e.trim())&&null!==function(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:new Date(e.getTime());if("number"==typeof e){const t=new Date(e);return Number.isNaN(t.getTime())?null:t}return N($(e).trim())}(e)}function Q(e,t){return G(e)?function(e){return`${String(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}(t):t.toISOString()}var V=e(function({value:e,locale:n,month:r,year:o,day:a,weekday:i,hour:u,minute:s,second:d,hour12:l,srLabel:c,"aria-label":m,...g},h){const f=Y(e),y=Z(f,{mode:"standard",...{...void 0!==n&&{locale:n},...void 0!==r&&{month:r},...void 0!==o&&{year:o},...void 0!==a&&{day:a},...void 0!==i&&{weekday:i},...void 0!==u&&{hour:u},...void 0!==s&&{minute:s},...void 0!==d&&{second:d},...void 0!==l&&{hour12:l}}}),b=Q(e,f);return t("time",{...g,ref:h,dateTime:b,"aria-label":c??m??y},y)});V.displayName="Tarikh";var X=e(function({value:e,locale:n,numeric:r,srLabel:o,"aria-label":a,...i},u){const s=Y(e),d={...void 0!==n&&{locale:n},...void 0!==r&&{numeric:r}},l=function(e,t){const n=Y(e),r=t?.locale??"en-BD",o=t?.numeric??"always",a="bn-BD"===r?y:f,i=Date.now()-n.getTime(),u=Math.abs(i),s=i>0,d=new Date,l=n.getFullYear()===d.getFullYear()&&n.getMonth()===d.getMonth()&&n.getDate()===d.getDate(),c=s?d:n,m=s?n:d;if(u<L)return a.justNow;if("auto"===o&&l)return function(e){return"bn-BD"===e?"আজ":"today"}(r);const g=P(c,m);if(g>=1){if("auto"===o&&1===g){const e=K("year",s,r);if(null!==e)return e}return z(g,a.year,a.years,s,r)}const h=q(c,m);if(h>=1){if("auto"===o&&1===h){const e=K("month",s,r);if(null!==e)return e}return z(h,a.month,a.months,s,r)}for(const e of W)if(u>=e.threshold){const t=Math.floor(u/e.threshold);if("auto"===o&&1===t&&("day"===e.singular||"week"===e.singular)){const t=K(e.singular,s,r);if(null!==t)return t}return z(t,a[e.singular],a[e.plural],s,r)}return a.justNow}(s,Object.keys(d).length>0?d:void 0),c=Q(e,s);return t("time",{...i,ref:u,dateTime:c,"aria-label":o??a??l},l)});X.displayName="RelativeTime";var _=e(function({value:e,locale:n,format:r,variant:o,srLabel:a,"aria-label":i,...u},s){const d=Y(e),l=Z(d,{mode:"bangla",...{...void 0!==n&&{locale:n},...void 0!==r&&{format:r},...void 0!==o&&{variant:o}}}),c=Q(e,d);return t("time",{...u,ref:s,dateTime:c,"aria-label":a??i??l},l)});_.displayName="BanglaDate";var ee=e(function({value:e,locale:n,timeZone:r,srLabel:o,"aria-label":a,...i},u){const s=Y(e),d=Z(s,{mode:"hijri",...{...void 0!==n&&{locale:n},...void 0!==r&&{timeZone:r}}}),l=Q(e,s);return t("time",{...i,ref:u,dateTime:l,"aria-label":o??a??d},d)});ee.displayName="HijriDate",V.Relative=X,V.Bangla=_,V.Hijri=ee;export{V as Tarikh};
package/package.json CHANGED
@@ -1,92 +1,94 @@
1
- {
2
- "name": "@coreify/tarikh",
3
- "version": "1.0.0",
4
- "description": "A modern Bangladesh-first date toolkit for formatting, Bangla calendar, and localization in JavaScript, TypeScript, and React apps.",
5
- "type": "module",
6
- "sideEffects": false,
7
- "main": "./dist/index.cjs",
8
- "module": "./dist/index.js",
9
- "types": "./dist/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "types": "./dist/index.d.ts",
13
- "import": "./dist/index.js",
14
- "require": "./dist/index.cjs"
15
- },
16
- "./react": {
17
- "types": "./dist/react.d.ts",
18
- "import": "./dist/react.js",
19
- "require": "./dist/react.cjs"
20
- },
21
- "./package.json": "./package.json"
22
- },
23
- "files": [
24
- "dist",
25
- "README.md",
26
- "LICENSE"
27
- ],
28
- "engines": {
29
- "node": ">=18"
30
- },
31
- "scripts": {
32
- "build": "tsup",
33
- "build:watch": "tsup --watch",
34
- "typecheck": "tsc --noEmit",
35
- "lint": "eslint .",
36
- "ci": "npm run lint && npm run typecheck && npm test",
37
- "test": "npm run build && vitest run",
38
- "test:unit": "vitest run",
39
- "test:watch": "vitest",
40
- "format": "prettier --write \"**/*.{ts,tsx,js,json,md}\""
41
- },
42
- "license": "MIT",
43
- "author": "Coreify",
44
- "repository": {
45
- "type": "git",
46
- "url": "git+https://github.com/coreify/tarikh.git"
47
- },
48
- "homepage": "https://tarikh.js.org",
49
- "bugs": {
50
- "url": "https://github.com/coreify/tarikh/issues"
51
- },
52
- "prepack": "npm run build",
53
- "publishConfig": {
54
- "access": "public"
55
- },
56
- "peerDependencies": {
57
- "react": ">=18"
58
- },
59
- "peerDependenciesMeta": {
60
- "react": {
61
- "optional": true
62
- }
63
- },
64
- "devDependencies": {
65
- "@eslint/js": "^10.0.1",
66
- "@types/node": "^25.5.0",
67
- "@types/react": "^19.2.14",
68
- "@types/react-dom": "^19.2.3",
69
- "eslint": "^10.1.0",
70
- "globals": "^17.4.0",
71
- "prettier": "^3.8.1",
72
- "react": "^19.2.4",
73
- "react-dom": "^19.2.4",
74
- "terser": "^5.46.1",
75
- "tsup": "^8.5.1",
76
- "typescript": "^5.9.3",
77
- "typescript-eslint": "^8.58.0",
78
- "vitest": "^4.1.2"
79
- },
80
- "keywords": [
81
- "tarikh",
82
- "date",
83
- "bangla",
84
- "bengali",
85
- "bangladesh",
86
- "calendar",
87
- "formatting",
88
- "localization",
89
- "react",
90
- "typescript"
91
- ]
92
- }
1
+ {
2
+ "name": "@coreify/tarikh",
3
+ "version": "1.0.2",
4
+ "description": "A modern Bangladesh-first date toolkit for formatting, Bangla calendar, Hijri calendar, and localization in JavaScript, TypeScript, and React apps.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ },
16
+ "./react": {
17
+ "types": "./dist/react.d.ts",
18
+ "import": "./dist/react.js",
19
+ "require": "./dist/react.cjs"
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "README.md",
26
+ "LICENSE"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "build:watch": "tsup --watch",
34
+ "typecheck": "tsc --noEmit",
35
+ "lint": "eslint .",
36
+ "ci": "npm run lint && npm run typecheck && npm test",
37
+ "test": "npm run build && vitest run",
38
+ "test:unit": "vitest run",
39
+ "test:watch": "vitest",
40
+ "format": "prettier --write \"**/*.{ts,tsx,js,json,md}\""
41
+ },
42
+ "license": "MIT",
43
+ "author": "Coreify",
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "git+https://github.com/coreify/tarikh.git"
47
+ },
48
+ "homepage": "https://tarikh.js.org",
49
+ "bugs": {
50
+ "url": "https://github.com/coreify/tarikh/issues"
51
+ },
52
+ "prepack": "npm run build",
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "peerDependencies": {
57
+ "react": ">=18"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "react": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "devDependencies": {
65
+ "@eslint/js": "^10.0.1",
66
+ "@types/node": "^25.5.0",
67
+ "@types/react": "^19.2.14",
68
+ "@types/react-dom": "^19.2.3",
69
+ "eslint": "^10.1.0",
70
+ "globals": "^17.4.0",
71
+ "prettier": "^3.8.1",
72
+ "react": "^19.2.4",
73
+ "react-dom": "^19.2.4",
74
+ "terser": "^5.46.1",
75
+ "tsup": "^8.5.1",
76
+ "typescript": "^5.9.3",
77
+ "typescript-eslint": "^8.58.0",
78
+ "vitest": "^4.1.2"
79
+ },
80
+ "keywords": [
81
+ "tarikh",
82
+ "date",
83
+ "bangla",
84
+ "bengali",
85
+ "bangladesh",
86
+ "hijri",
87
+ "islamic",
88
+ "calendar",
89
+ "formatting",
90
+ "localization",
91
+ "react",
92
+ "typescript"
93
+ ]
94
+ }