UNPKG

gize

Version:

![npm](https://img.shields.io/npm/v/gize) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/elias-ela/gize/Build-Test) [![Coverage Status](https://coveralls.io/repos/github/elias-ela/gize/badge.svg?branch=main)](https://coveralls.io/

3 lines (2 loc) 18.7 kB
function e(e,t){if("number"==typeof t)return e<0&&e>-10?"-"+(Array(t+1).join("0")+Math.abs(parseInt(e.toString()))):e>=10?e:Array(t+1).join("0")+e;if("string"==typeof t)return t+e;throw new TypeError("Expected string or number, got '"+t+"'.")}var t=function(e,t){if(e.length<t)throw new TypeError(t+" argument"+(t>1?"s":"")+" required, but only "+e.length+" given.")},n=719163,i=2796,r=1e3,o=6e4,a=36e5,u=864e5,m=6048e5,s=5500,h=3;function l(e){return t(arguments,1),n+Math.floor(e/864e5)}function c(e){var n=e.year,r=e.month,o=e.day;return t(arguments,1),Math.floor(i-1+365*(Number(n)-1)+Number(n)/4+30*(Number(r)-1)+Number(o))}function g(e){t(arguments,1);var i=e.year,m=e.month,s=e.day,h=e.hour,l=e.minute,g=e.second,d=e.millisecond;return(c({year:Number(i),month:Number(m),day:Number(s)})-n)*u+Number(h)*a+Number(l)*o+Number(g)*r+Number(d)}function d(e){var t={moment:Date.now(),locale:"am",hour12:!0};if(0===e.length)t.moment=Date.now();else if(1===e.length)t.moment=Number(e[0]);else if(3===e.length){var n=e[0],i=e[1],r=e[2];t.moment=g({year:Number(n),month:Number(i),day:Number(r),hour:0,minute:0,second:0,millisecond:0})}else if(6===e.length){n=e[0],i=e[1],r=e[2];var o=e[3],a=e[4],u=e[5];t.moment=g({year:Number(n),month:Number(i),day:Number(r),hour:Number(o),minute:Number(a),second:Number(u),millisecond:0})}else{if(7!==e.length)throw new TypeError("Invalid Argument "+e);n=e[0],i=e[1],r=e[2],o=e[3],a=e[4],u=e[5];var m=e[6];t.moment=g({year:Number(n),month:Number(i),day:Number(r),hour:Number(o),minute:Number(a),second:Number(u),millisecond:Number(m)})}return t}var f=function(e,t){return e[t]},y={en:{monthNames:"September_October_November_December_January_February_March_April_May_June_July_August_Pagumen".split("_"),dayNames:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_")},am:{monthNames:"መስከረም_ጥቅምት_ኅዳር_ታኅሳስ_ጥር_የካቲት_መጋቢት_ሚያዝያ_ግንቦት_ሰኔ_ሐምሌ_ነሐሴ_ጷጉሜን".split("_"),dayNames:"እሁድ_ሰኞ_ማክሰኞ_ረቡዕ_ሐሙስ_አርብ_ቅዳሜ".split("_")},or:{monthNames:"Fulbaana_Onkololeessa_Sadaasa_Muddee_Ammajjii_Guraandhala_Bitootess_Ebla_Caamsaa_Waxabajjii_Adoolessa_Hagayya_Qaammee".split("_"),dayNames:"Sambata_Wixata_Kibxata_Roobii_Kamisa_Jimaata_Dilbata".split("_")},ti:{monthNames:"መስከረም_ጥቅምቲ_ሕዳር_ታሕሳስ_ጥሪ_ለካቲት_መጋቢት_ሚያዝያ_ግንቦት_ ሰነ_ሓምለ_ነሓሰ_ጷጉሜን".split("_"),dayNames:"ሰንበት_ሰኑይ_ሰሉስ_ረቡዕ_ሓሙስ_ዓርቢ_ቀዳም".split("_")},ge:{monthNames:"ከረመ_ጠቀመ_ኀደረ_ኀሠሠ_ጠሐር_ከተተ_መገበ_አኀዘ_ግንባት_ሠነየ_ሐመለ_ነሐሰ_ጳጕሜን".split("_"),dayNames:"እሁድ_ሰኞ_ማክሰኞ_ረቡዕ_ሐሙስ_አርብ_ቅዳሜ".split("_")},am_en:{monthNames:"Meskerem_Tikemet_Hidar_Tahesas_Tir_Yekatit_Megabit_Miazia_Genbot_Sene_Hamle_Nehase_Pagume".split("_"),dayNames:"Ehud_Segno_Maksegno_Irob_Hamus_Arb_Kidame".split("_")},en_am:{monthNames:"ሴፕቴምበር_ኦክቶበር_ኖቬምበር_ዲሴምበር_ጃንዋሪ_ፈብርዋሪ_ማርች_አፕሪል_ሜይ_ጁን_ጁላይ_ኦገስት".split("_"),dayNames:"ሰንዴይ_መንዴይ_ትዩስዴይ_ዌንስዴይ_ተርሰዴይ_ፍራይዴይ_ሳተርዴይ".split("_")}},_=function(){function n(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.initialValues=d(e)}return n.prototype.toNumber=function(e){var t=e.year,n=e.month,i=e.day,r=e.hour,o=e.minute,a=e.second,u=e.millisecond;return{year:t=void 0!==t?Number(t):this.getFullYear(),month:n=void 0!==n?Number(n):this.getMonth(),day:i=void 0!==i?Number(i):this.getDate(),hour:r=void 0!==r?Number(r):this.getUTCHours(),minute:o=void 0!==o?Number(o):this.getMinutes(),second:a=void 0!==a?Number(a):this.getSeconds(),millisecond:u=void 0!==u?Number(u):this.getMilliseconds()}},n.prototype.getString=function(){var e,t=(e=this.initialValues.locale,f(y,e)),n=this.getDay(),i=this.getMonth();return{dayName:null==t?void 0:t.dayNames[n].trim(),monthName:null==t?void 0:t.monthNames[i-1].trim(),timezone:h}},n.prototype.getDatetime=function(){return{year:e(this.getFullYear(),1),month:e(this.getMonth(),1),day:e(this.getDate(),1),hour:e(this.getHours(),1),minute:e(this.getMinutes(),1),second:e(this.getSeconds(),1),millisecond:this.getMilliseconds()}},n.prototype.setDatetime=function(e){var t=this.toNumber(e);return this.initialValues.moment=g(t),this},n.prototype.toString=function(){var t=this.getDatetime(),n=t.year,i=t.day,r=t.hour,o=t.minute,a=t.second,u=this.getString();return u.dayName+" "+u.monthName+" "+i+" "+n+" "+r+":"+o+":"+a+" GMT+"+e(u.timezone,1)+"00"},n.prototype.toDateString=function(){var e=this.getDatetime(),t=e.year,n=e.day,i=this.getString();return i.dayName+" "+i.monthName+" "+n+" "+t},n.prototype.toTimeString=function(){var t=this.getDatetime();return t.hour+":"+t.minute+":"+t.second+" GMT+"+e(h,1)+"00"},n.prototype.toLocaleString=function(){var e=this.getDatetime(),t=e.year,n=e.month;return e.day+"/"+n+"/"+t+", "+e.hour+":"+e.minute+":"+e.second+" "+this.getMeridiem()},n.prototype.toLocaleDateString=function(){var e=this.getDatetime(),t=e.year,n=e.month;return e.day+"/"+n+"/"+t},n.prototype.toLocaleTimeString=function(){var e=this.getDatetime();return e.hour+":"+e.minute+":"+e.second+" "+this.getMeridiem()},n.prototype.valueOf=function(){return this.getTime()},n.prototype.getMeridiem=function(){return this.initialValues.hour12?this.getHours()>=12?"PM":"AM":""},n.prototype.getTime=function(){return this.initialValues.moment},n.prototype.getFullYear=function(){return Math.floor((4*(l(this.initialValues.moment)-i)+1463)/1461)},n.prototype.getMonth=function(){return Math.floor((l(this.initialValues.moment)-c({year:this.getFullYear(),month:1,day:1}))/30)+1},n.prototype.getDate=function(){return l(this.initialValues.moment)+1-c({year:this.getFullYear(),month:this.getMonth(),day:1})},n.prototype.getDay=function(){var e=s+this.getFullYear();return(e+Math.floor(e/4)+(30*(this.getMonth()-1)+this.getDate()))%7},n.prototype.getHours=function(){return this.initialValues.hour12?(this.getUTCHours()+h)%12||12:this.getUTCHours()+h},n.prototype.getUTCHours=function(){return Math.floor(this.initialValues.moment/a)%24},n.prototype.getMinutes=function(){return Math.floor(Math.abs(this.initialValues.moment/o))%60},n.prototype.getSeconds=function(){return Math.floor(Math.abs(this.initialValues.moment/r))%60},n.prototype.getMilliseconds=function(){return Math.abs(this.initialValues.moment%1e3)},n.prototype.getTimezoneOffset=function(){return 60*-h},n.prototype.setTime=function(e){return t(arguments,1),this.initialValues.moment=Number(e),this},n.prototype.setMilliseconds=function(e){return t(arguments,1),this.setDatetime({millisecond:e})},n.prototype.setSeconds=function(e,n){return t(arguments,1),this.setDatetime({second:e,millisecond:n})},n.prototype.setMinutes=function(e,n,i){return t(arguments,1),this.setDatetime({minute:e,second:n,millisecond:i})},n.prototype.setHours=function(e,n,i,r){return t(arguments,1),this.setDatetime({hour:e,minute:n,second:i,millisecond:r})},n.prototype.setDate=function(e){return t(arguments,1),this.setDatetime({day:e})},n.prototype.setMonth=function(e,n){return t(arguments,1),this.setDatetime({month:e,day:n})},n.prototype.setFullYear=function(e,n,i){return t(arguments,1),this.setDatetime({year:e,month:n,day:i})},n.prototype.toISOString=function(){var t=this.getDatetime(),n=t.year,i=t.month,r=t.day,o=t.minute,a=t.second,u=t.millisecond;return n+"-"+i+"-"+r+"T"+e(this.getUTCHours(),1)+":"+o+":"+a+"."+u+"Z"},n.prototype.toJSON=function(e){return this.toISOString()},n}(),p=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.length;switch(n){case 1:this.jdn=e[0];break;case 3:this.year=e[0],this.month=e[1],this.day=e[2];break;case 4:this.year=e[0],this.month=e[1],this.day=e[2],void 0!==e[3]&&(this.jdn=e[3]);break;case 6:this.year=e[0],this.month=e[1],this.day=e[2],void 0!==e[3]&&(this.hour=e[3]),void 0!==e[4]&&(this.minute=e[4]),void 0!==e[5]&&(this.second=e[5]);break;case 7:this.year=e[0],this.month=e[1],this.day=e[2],void 0!==e[3]&&(this.hour=e[3]),void 0!==e[4]&&(this.minute=e[4]),void 0!==e[5]&&(this.second=e[5]),void 0!==e[6]&&(this.millisecond=e[6])}},T=function(e,t){return(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};var v=function(e){function t(t){var n=e.call(this,t)||this;return n.error=t,n}return function(e,t){function n(){this.constructor=e}T(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t}(Error),N=function(e,t){return e-t*Math.floor(e/t)},w=function(){function e(){}return e.prototype.isLeap=function(e){return 3===N(e,4)},e.prototype.toJDN=function(e,t,n){return this.validator(e,t,n),1724219.5+365*(e-1)+Math.floor(e/4)+30*(t-1)+n},e.prototype.fromJDN=function(e){var t=Math.floor((4*(e-1724220.5)+1463)/1461),n=1+Math.floor((e-this.toJDN(t,1,1))/30),i=e+1-this.toJDN(t,n,1);return new p(t,n,i,e)},e.prototype.validator=function(e,t,n){if(t<1||t>13)throw new v("INVALID_MONTH");var i=this.isLeap(e)?6:5;if(13===t&&n>i)throw new v("INVALID_LEAP_DAY");if(n<1||n>30)throw new v("INVALID_DAY");return!0},e}(),M=[31,28,31,30,31,30,31,31,30,31,30,31],b=function(){function e(){this.jdnToYear=function(e){var t=Math.floor(e-.5)+.5-1721425.5,n=Math.floor(t/146097),i=N(t,146097),r=Math.floor(i/36524),o=N(i,36524),a=Math.floor(o/1461),u=N(o,1461),m=Math.floor(u/365);return 400*n+100*r+4*a+m+(4!==r&&4!==m?1:0)}}return e.prototype.isLeap=function(e){return e%4==0&&(e%100!=0||e%400==0)},e.prototype.toJDN=function(e,t,n){this.validator(e,t,n);var i=e-1,r=this.isLeap(e);return 1721424.5+365*i+Math.floor(i/4)-Math.floor(i/100)+Math.floor(i/400)+Math.floor((367*t-362)/12+(t<=2?0:r?-1:-2)+n)},e.prototype.fromJDN=function(e){var t=Math.floor(e-.5)+.5,n=this.jdnToYear(t),i=t-this.toJDN(n,1,1),r=this.isLeap(n),o=t<this.toJDN(n,3,1)?0:r?1:2,a=Math.floor((12*(i+o)+373)/367),u=t-this.toJDN(n,a,1)+1;return new p(n,a,u,e)},e.prototype.validator=function(e,t,n){if(t<1||t>12)throw new v("INVALID_MONTH");if(n<1)throw new v("INVALID_DAY");if(M[1]=this.isLeap(e)?29:28,2===t&&n>M[1])throw new v("INVALID_LEAP_DAY");if(M[t-1]<n)throw new v("INVALID_DAY");return!0},e}(),D=new w,S=new b,A=function(e,t,n){var i=S.toJDN(e,t,n);return D.fromJDN(i)},E=function(e,t,n){var i=D.toJDN(e,t,n);return S.fromJDN(i)};function Y(e,n){t(arguments,2);var i=new _(e.getTime()),r=i.getMilliseconds()+Number(n);return i.setMilliseconds(r)}function I(e,n,i){return t(arguments,2),j(e,{second:n,millisecond:i})}function V(e,n,i,r){return t(arguments,2),j(e,{minute:n,second:i,millisecond:r})}function H(e,n,i,r,o){return t(arguments,2),j(e,{hour:n,minute:i,second:r,millisecond:o})}function F(e,n){return t(arguments,2),j(e,{day:n})}function J(e,n,i){return t(arguments,2),n=Number(n)+e.getMonth(),e.setMonth(n)}function L(e,n,i,r){return t(arguments,2),j(e,{year:n,month:i,day:r})}function j(e,n){t(arguments,2);var i=n.year,r=n.month,o=n.day,a=n.hour,u=n.minute,m=n.second,s=n.millisecond,h=new _(e.getTime());return i=void 0!==i?Number(i)+h.getFullYear():h.getFullYear(),r=void 0!==r?Number(r)+h.getMonth():h.getMonth(),o=void 0!==o?Number(o)+h.getDate():h.getDate(),a=void 0!==a?Number(a)+h.getUTCHours():h.getUTCHours(),u=void 0!==u?Number(u)+h.getMinutes():h.getMinutes(),m=void 0!==m?Number(m)+h.getSeconds():h.getSeconds(),s=void 0!==s?Number(s)+h.getMilliseconds():h.getMilliseconds(),h.setDatetime({year:i,month:r,day:o,hour:a,minute:u,second:m,millisecond:s})}var O=function(e,t){return t in e},C=function(e,t){return e-t};function k(e,n){if(t(arguments,2),"object"!=typeof n)return new _(NaN);var i=new _(e.getTime()),r=n.year,o=n.month,a=n.day,u=n.hour,m=n.minute,s=n.second,h=n.millisecond;return r=O(n,"year")?C(i.getFullYear(),Number(r)):i.getFullYear(),o=O(n,"month")?C(i.getMonth(),Number(o)):i.getMonth(),a=O(n,"day")?C(i.getDate(),Number(a)):i.getDate(),u=O(n,"hour")?C(i.getUTCHours(),Number(u)):i.getUTCHours(),m=O(n,"minute")?C(i.getMinutes(),Number(m)):i.getMinutes(),s=O(n,"second")?C(i.getSeconds(),Number(s)):i.getSeconds(),h=O(n,"millisecond")?C(i.getMilliseconds(),Number(h)):i.getMilliseconds(),i.setDatetime({year:r,month:o,day:a,hour:u,minute:m,second:s,millisecond:h})}function U(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return i.getTime()===r.getTime()}function x(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return i.getTime()>r.getTime()}function P(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return i.getTime()>=r.getTime()}function z(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return i.getTime()<r.getTime()}function G(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return i.getTime()<=r.getTime()}function K(e,n,i){t(arguments,3);var r=new _(e.getTime()),o=new _(n.getTime()),a=new _(i.getTime());return r.getTime()>=o.getTime()&&r.getTime()<=a.getTime()}function W(e){if(t(arguments,1),!e&&!Array.isArray(e))throw new TypeError("Expected an array, "+arguments+" provided.");var n=[];e.forEach((function(e){if(void 0===e.getTime()||isNaN(e.getTime()))throw new TypeError("Invalid EthiopicDatetime: "+e);n.push(new _(e.getTime()))}));var i=n[0];return n.forEach((function(e){e.getTime()<i.getTime()&&(i=e)})),new _(i.getTime())}function q(e){if(t(arguments,1),!e&&!Array.isArray(e))throw new TypeError("Expected an array, "+arguments+" provided.");var n=[];e.forEach((function(e){if(void 0===e.getTime()||isNaN(e.getTime()))throw new TypeError("Invalid EthiopicDatetime: "+e);n.push(new _(e.getTime()))}));var i=n[0];return n.forEach((function(e){e.getTime()>i.getTime()&&(i=e)})),new _(i.getTime())}function B(e){t(arguments,1);var n=k(new _,{day:1}).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});return n.getTime()===i.getTime()}function Q(e){t(arguments,1);var n=(new _).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});return n.getTime()===i.getTime()}function R(e){t(arguments,1);var n=F(new _,1).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});return n.getTime()===i.getTime()}function Z(e){t(arguments,1);var n=(new _).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=n.getTime()-i.getTime();return r>=864e5}function X(e){t(arguments,1);var n=(new _).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=i.getTime()-n.getTime(),o=864e5;return r>o}function $(e,n){t(arguments,2);var i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=new _(n.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),o=Math.abs(r.getTime()-i.getTime());return 0===o}function ee(e,n){t(arguments,2);var i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=new _(n.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),o=Math.abs(i.getFullYear()-r.getFullYear());return 0===o}function te(e,n){t(arguments,2);var i=new _(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=new _(n.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});if(0!==Math.abs(i.getFullYear()-r.getFullYear()))return!1;var o=Math.abs(r.getMonth()-i.getMonth());return 0===o}function ne(e){t(arguments,1);var n=new _(e.getTime());if(void 0===n.getTime||isNaN(n.getTime()))throw new TypeError("Expected EthiopicDatetime, "+arguments[0]+" provided.");return!(6===n.getDay()||0===n.getDay())}function ie(e){t(arguments,1);var n=new _(e.getTime());return!ne(n)}function re(e){t(arguments,1);var n=new _(e.getTime());return 1===n.getDay()}function oe(e){t(arguments,1);var n=new _(e.getTime());return 2===n.getDay()}function ae(e){t(arguments,1);var n=new _(e.getTime());return 3===n.getDay()}function ue(e){t(arguments,1);var n=new _(e.getTime());return 4===n.getDay()}function me(e){t(arguments,1);var n=new _(e.getTime());return 5===n.getDay()}function se(e){t(arguments,1);var n=new _(e.getTime());return 6===n.getDay()}function he(e){t(arguments,1);var n=new _(e.getTime());return 0===n.getDay()}function le(e,n){t(arguments,2);var i=ce(e,n),m={year:"",month:"",day:0,hour:0,minute:0,second:0,millisecond:0};return m.day=Math.floor(i/u),m.hour=Math.floor((i%=u)/a),m.minute=Math.floor((i%=a)/o),m.second=Math.floor(i%o/r),m.millisecond=Math.floor(i%r),m}function ce(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return r.getTime()-i.getTime()}function ge(e,n){t(arguments,2);var i=new _(e.getTime()),o=new _(n.getTime());return Math.floor((o.getTime()-i.getTime())/r)}function de(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return Math.floor((r.getTime()-i.getTime())/o)}function fe(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return Math.floor((r.getTime()-i.getTime())/a)}function ye(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return Math.floor((r.getTime()-i.getTime())/u)}function _e(e,n){t(arguments,2);var i=new _(e.getTime()),r=new _(n.getTime());return Math.floor((r.getTime()-i.getTime())/m)}function pe(e,n){t(arguments,2);for(var i=new _(n.getTime()),r=new _(e.getTime()),o=0;r.getTime()<i.getTime();){var a=r.getMonth();r.setMonth(a+1),o+=1}return r.getTime()!==i.getTime()&&(o-=1),o}function Te(e,n){t(arguments,2);var i=pe(e,n);return Math.ceil(i/13)}export{_ as EthiopicDatetime,j as addDatetime,F as addDays,L as addFullYears,H as addHours,Y as addMilliseconds,V as addMinutes,J as addMonths,I as addSeconds,le as differenceInDatetime,ye as differenceInDays,fe as differenceInHours,ce as differenceInMilliseconds,de as differenceInMinutes,pe as differenceInMonths,ge as differenceInSeconds,_e as differenceInWeeks,Te as differenceInYears,D as ethiopicCalendar,S as gregorianCalendar,x as isAfter,P as isAfterOrEqual,z as isBefore,G as isBeforeOrEqual,K as isBetween,U as isEqual,me as isFriday,X as isFuture,re as isMonday,Z as isPast,$ as isSameDay,te as isSameMonth,ee as isSameYear,se as isSaturday,he as isSunday,ue as isThursday,Q as isToday,R as isTomorrow,oe as isTuesday,ae as isWednesday,ne as isWeekday,ie as isWeekend,B as isYesterday,q as max,W as min,k as subDatetime,A as toEthiopic,E as toGregorian}; //# sourceMappingURL=gize.es.min.js.map