gize
Version:
  [](https://coveralls.io/
3 lines (2 loc) • 18.8 kB
JavaScript
"use strict";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+"'.")}Object.defineProperty(exports,"__esModule",{value:!0});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,s=864e5,u=6048e5,m=5500,h=3;function c(e){return t(arguments,1),n+Math.floor(e/864e5)}function l(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 d(e){t(arguments,1);var i=e.year,u=e.month,m=e.day,h=e.hour,c=e.minute,d=e.second,g=e.millisecond;return(l({year:Number(i),month:Number(u),day:Number(m)})-n)*s+Number(h)*a+Number(c)*o+Number(d)*r+Number(g)}function g(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=d({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],s=e[5];t.moment=d({year:Number(n),month:Number(i),day:Number(r),hour:Number(o),minute:Number(a),second:Number(s),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],s=e[5];var u=e[6];t.moment=d({year:Number(n),month:Number(i),day:Number(r),hour:Number(o),minute:Number(a),second:Number(s),millisecond:Number(u)})}return t}var f=function(e,t){return e[t]},p={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("_")}},y=function(){function n(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.initialValues=g(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,s=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:s=void 0!==s?Number(s):this.getMilliseconds()}},n.prototype.getString=function(){var e,t=(e=this.initialValues.locale,f(p,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=d(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,s=this.getString();return s.dayName+" "+s.monthName+" "+i+" "+n+" "+r+":"+o+":"+a+" GMT+"+e(s.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*(c(this.initialValues.moment)-i)+1463)/1461)},n.prototype.getMonth=function(){return Math.floor((c(this.initialValues.moment)-l({year:this.getFullYear(),month:1,day:1}))/30)+1},n.prototype.getDate=function(){return c(this.initialValues.moment)+1-l({year:this.getFullYear(),month:this.getMonth(),day:1})},n.prototype.getDay=function(){var e=m+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,s=t.millisecond;return n+"-"+i+"-"+r+"T"+e(this.getUTCHours(),1)+":"+o+":"+a+"."+s+"Z"},n.prototype.toJSON=function(e){return this.toISOString()},n}(),_=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)},M=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 _(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}(),w=[31,28,31,30,31,30,31,31,30,31,30,31],D=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),s=N(o,1461),u=Math.floor(s/365);return 400*n+100*r+4*a+u+(4!==r&&4!==u?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),s=t-this.toJDN(n,a,1)+1;return new _(n,a,s,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(w[1]=this.isLeap(e)?29:28,2===t&&n>w[1])throw new v("INVALID_LEAP_DAY");if(w[t-1]<n)throw new v("INVALID_DAY");return!0},e}(),b=new M,x=new D;function S(e,n){return t(arguments,2),A(e,{day:n})}function A(e,n){t(arguments,2);var i=n.year,r=n.month,o=n.day,a=n.hour,s=n.minute,u=n.second,m=n.millisecond,h=new y(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(),s=void 0!==s?Number(s)+h.getMinutes():h.getMinutes(),u=void 0!==u?Number(u)+h.getSeconds():h.getSeconds(),m=void 0!==m?Number(m)+h.getMilliseconds():h.getMilliseconds(),h.setDatetime({year:i,month:r,day:o,hour:a,minute:s,second:u,millisecond:m})}var I=function(e,t){return t in e},E=function(e,t){return e-t};function Y(e,n){if(t(arguments,2),"object"!=typeof n)return new y(NaN);var i=new y(e.getTime()),r=n.year,o=n.month,a=n.day,s=n.hour,u=n.minute,m=n.second,h=n.millisecond;return r=I(n,"year")?E(i.getFullYear(),Number(r)):i.getFullYear(),o=I(n,"month")?E(i.getMonth(),Number(o)):i.getMonth(),a=I(n,"day")?E(i.getDate(),Number(a)):i.getDate(),s=I(n,"hour")?E(i.getUTCHours(),Number(s)):i.getUTCHours(),u=I(n,"minute")?E(i.getMinutes(),Number(u)):i.getMinutes(),m=I(n,"second")?E(i.getSeconds(),Number(m)):i.getSeconds(),h=I(n,"millisecond")?E(i.getMilliseconds(),Number(h)):i.getMilliseconds(),i.setDatetime({year:r,month:o,day:a,hour:s,minute:u,second:m,millisecond:h})}function F(e){t(arguments,1);var n=new y(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 H(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return r.getTime()-i.getTime()}function V(e,n){t(arguments,2);for(var i=new y(n.getTime()),r=new y(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}exports.EthiopicDatetime=y,exports.addDatetime=A,exports.addDays=S,exports.addFullYears=function(e,n,i,r){return t(arguments,2),A(e,{year:n,month:i,day:r})},exports.addHours=function(e,n,i,r,o){return t(arguments,2),A(e,{hour:n,minute:i,second:r,millisecond:o})},exports.addMilliseconds=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=i.getMilliseconds()+Number(n);return i.setMilliseconds(r)},exports.addMinutes=function(e,n,i,r){return t(arguments,2),A(e,{minute:n,second:i,millisecond:r})},exports.addMonths=function(e,n,i){return t(arguments,2),n=Number(n)+e.getMonth(),e.setMonth(n)},exports.addSeconds=function(e,n,i){return t(arguments,2),A(e,{second:n,millisecond:i})},exports.differenceInDatetime=function(e,n){t(arguments,2);var i=H(e,n),u={year:"",month:"",day:0,hour:0,minute:0,second:0,millisecond:0};return u.day=Math.floor(i/s),u.hour=Math.floor((i%=s)/a),u.minute=Math.floor((i%=a)/o),u.second=Math.floor(i%o/r),u.millisecond=Math.floor(i%r),u},exports.differenceInDays=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return Math.floor((r.getTime()-i.getTime())/s)},exports.differenceInHours=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return Math.floor((r.getTime()-i.getTime())/a)},exports.differenceInMilliseconds=H,exports.differenceInMinutes=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return Math.floor((r.getTime()-i.getTime())/o)},exports.differenceInMonths=V,exports.differenceInSeconds=function(e,n){t(arguments,2);var i=new y(e.getTime()),o=new y(n.getTime());return Math.floor((o.getTime()-i.getTime())/r)},exports.differenceInWeeks=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return Math.floor((r.getTime()-i.getTime())/u)},exports.differenceInYears=function(e,n){t(arguments,2);var i=V(e,n);return Math.ceil(i/13)},exports.ethiopicCalendar=b,exports.gregorianCalendar=x,exports.isAfter=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return i.getTime()>r.getTime()},exports.isAfterOrEqual=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return i.getTime()>=r.getTime()},exports.isBefore=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return i.getTime()<r.getTime()},exports.isBeforeOrEqual=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return i.getTime()<=r.getTime()},exports.isBetween=function(e,n,i){t(arguments,3);var r=new y(e.getTime()),o=new y(n.getTime()),a=new y(i.getTime());return r.getTime()>=o.getTime()&&r.getTime()<=a.getTime()},exports.isEqual=function(e,n){t(arguments,2);var i=new y(e.getTime()),r=new y(n.getTime());return i.getTime()===r.getTime()},exports.isFriday=function(e){t(arguments,1);var n=new y(e.getTime());return 5===n.getDay()},exports.isFuture=function(e){t(arguments,1);var n=(new y).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=i.getTime()-n.getTime(),o=864e5;return r>o},exports.isMonday=function(e){t(arguments,1);var n=new y(e.getTime());return 1===n.getDay()},exports.isPast=function(e){t(arguments,1);var n=(new y).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=n.getTime()-i.getTime();return r>=864e5},exports.isSameDay=function(e,n){t(arguments,2);var i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=new y(n.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),o=Math.abs(r.getTime()-i.getTime());return 0===o},exports.isSameMonth=function(e,n){t(arguments,2);var i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=new y(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},exports.isSameYear=function(e,n){t(arguments,2);var i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),r=new y(n.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0}),o=Math.abs(i.getFullYear()-r.getFullYear());return 0===o},exports.isSaturday=function(e){t(arguments,1);var n=new y(e.getTime());return 6===n.getDay()},exports.isSunday=function(e){t(arguments,1);var n=new y(e.getTime());return 0===n.getDay()},exports.isThursday=function(e){t(arguments,1);var n=new y(e.getTime());return 4===n.getDay()},exports.isToday=function(e){t(arguments,1);var n=(new y).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});return n.getTime()===i.getTime()},exports.isTomorrow=function(e){t(arguments,1);var n=S(new y,1).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});return n.getTime()===i.getTime()},exports.isTuesday=function(e){t(arguments,1);var n=new y(e.getTime());return 2===n.getDay()},exports.isWednesday=function(e){t(arguments,1);var n=new y(e.getTime());return 3===n.getDay()},exports.isWeekday=F,exports.isWeekend=function(e){t(arguments,1);var n=new y(e.getTime());return!F(n)},exports.isYesterday=function(e){t(arguments,1);var n=Y(new y,{day:1}).setDatetime({hour:0,minute:0,second:0,millisecond:0}),i=new y(e.getTime()).setDatetime({hour:0,minute:0,second:0,millisecond:0});return n.getTime()===i.getTime()},exports.max=function(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 y(e.getTime()))}));var i=n[0];return n.forEach((function(e){e.getTime()>i.getTime()&&(i=e)})),new y(i.getTime())},exports.min=function(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 y(e.getTime()))}));var i=n[0];return n.forEach((function(e){e.getTime()<i.getTime()&&(i=e)})),new y(i.getTime())},exports.subDatetime=Y,exports.toEthiopic=function(e,t,n){var i=x.toJDN(e,t,n);return b.fromJDN(i)},exports.toGregorian=function(e,t,n){var i=b.toJDN(e,t,n);return x.fromJDN(i)};
//# sourceMappingURL=gize.cjs.min.js.map