Comparing version 2.2.1 to 2.2.2
@@ -5,2 +5,11 @@ # Change Log | ||
## [2.2.2](https://github.com/alibaba-aero/jalaliday/compare/v2.2.1...v2.2.2) (2019-03-14) | ||
### Bug Fixes | ||
* **toArray:** override toArray if exists ([00c6548](https://github.com/alibaba-aero/jalaliday/commit/00c6548)) | ||
## [2.2.1](https://github.com/alibaba-aero/jalaliday/compare/v2.2.0...v2.2.1) (2019-03-10) | ||
@@ -7,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function _slicedToArray(t,r){return _arrayWithHoles(t)||_iterableToArrayLimit(t,r)||_nonIterableRest()}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _iterableToArrayLimit(t,r){var n=[],i=!0,e=!1,a=void 0;try{for(var s,o=t[Symbol.iterator]();!(i=(s=o.next()).done)&&(n.push(s.value),!r||n.length!==r);i=!0);}catch(t){e=!0,a=t}finally{try{i||null==o.return||o.return()}finally{if(e)throw a}}return n}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var $floor=Math.floor;function mod(t,r){return t-r*$floor(t/r)}function lg(t){return t%4==0&&!(t%100==0&&t%400!=0)}var GE=1721425.5;function g2j(t,r,n){return GE-1+365*(t-1)+$floor((t-1)/4)+-$floor((t-1)/100)+$floor((t-1)/400)+$floor((367*r-362)/12+(r<=2?0:lg(t)?-1:-2)+n)}function j2g(t){var r,n,i,e,a,s,o,h,u,d,f,l;r=$floor(t-.5)+.5,i=$floor((n=r-GE)/146097),e=mod(n,146097),a=$floor(e/36524),s=mod(e,36524),o=$floor(s/1461),h=mod(s,1461),d=400*i+100*a+4*o+(u=$floor(h/365)),4!=a&&4!=u&&d++,f=r-g2j(d,1,1),l=r<g2j(d,3,1)?0:lg(d)?1:2;var c=$floor((12*(f+l)+373)/367);return[d,c,r-g2j(d,c,1)+1]}var PE=1948320.5;function p2j(t,r,n){var i,e;return e=474+mod(i=t-(t>=0?474:473),2820),n+(r<=7?31*(r-1):30*(r-1)+6)+$floor((682*e-110)/2816)+365*(e-1)+1029983*$floor(i/2820)+(PE-1)}function j2p(t){var r,n,i,e,a,s,o,h,u;return i=(t=$floor(t)+.5)-p2j(475,1,1),e=$floor(i/1029983),1029982==(a=mod(i,1029983))?s=2820:(o=$floor(a/366),h=mod(a,366),s=$floor((2134*o+2816*h+2815)/1028522)+o+1),(r=s+2820*e+474)<=0&&r--,[r,n=(u=t-p2j(r,1,1)+1)<=186?Math.ceil(u/31):Math.ceil((u-6)/30),t-p2j(r,n,1)+1]}var jdate={J:function(t,r,n){return j2p(g2j(t,r,n))},G:function(t,r,n){return j2g(p2j(t,r,n))}},REGEX_PARSE=/^(\d{4})[-/]?(\d{1,2})[-/]?(\d{0,2})(.*)?$/,REGEX_FORMAT=/\[.*?\]|jY{2,4}|jM{1,4}|jD{1,2}|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,DATE="date",D="day",M="month",Y="year",W="week",FORMAT_DEFAULT="YYYY-MM-DDTHH:mm:ssZ",fa={name:"fa",weekdays:"یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه".split("_"),months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),jmonths:"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_"),ordinal:function(t){return t},relativeTime:{future:"در %s ثانیهی آتی",past:"%s پیش",s:"چند ثانیه پیش",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}},plugin=function(t,r,n){var i=r.prototype,e=i.$utils(),a=function(t){return"jalali"===t.$C},s=e.prettyUnit,o=e.isUndefined,h=e.padStart,u=e.monthDiff,d=e.absFloor,f=function(t){return function(){var r=t.bind(this).apply(void 0,arguments);return r.$C=this.$C,r.isJalali()&&r.InitJalali(),r}};i.startOf=f(i.startOf),i.endOf=f(i.endOf),i.add=f(i.add),i.subtract=f(i.subtract),i.set=f(i.set);var l=i.parse,c=i.init,$=i.startOf,j=i.$set,_=i.add,y=i.format,v=i.diff,m=i.year,b=i.month,p=i.date,g=i.daysInMonth,A=i.toArray;n.$C="gregory",n.$fdow=6,n.calendar=function(t){return n.$C=t,n},i.calendar=function(t){var r=this.clone();return r.$C=t,r.isJalali()&&r.InitJalali(),r},i.isJalali=function(){return a(this)},n.en.jmonths="Farvardin_Ordibehesht_Khordaad_Tir_Mordaad_Shahrivar_Mehr_Aabaan_Aazar_Dey_Bahman_Esfand".split("_"),n.locale("fa",fa,!0);var E=function(t,r){return n(t,{locale:r.$L,calendar:r.$C})};i.init=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c.bind(this)(t),this.isJalali()&&this.InitJalali()},i.parse=function(t){var r;if(this.$C=t.calendar||this.$C||n.$C,t.jalali&&"string"==typeof t.date&&/.*[^Z]$/i.test(t.date)&&(r=t.date.match(REGEX_PARSE))){var i=_slicedToArray(jdate.G(parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3]||1,10)),3),e=i[0],a=i[1],s=i[2];t.date="".concat(e,"-").concat(a,"-").concat(s).concat(r[4]||"")}return l.bind(this)(t)},i.InitJalali=function(){var t=_slicedToArray(jdate.J(this.$y,this.$M+1,this.$D),3),r=t[0],n=t[1],i=t[2];this.$jy=r,this.$jM=n-1,this.$jD=i},i.startOf=function(t,r){var i=this;if(!a(this))return $.bind(this)(t,r);var e=!!o(r)||r,h=s(t),u=function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.$jy,a=_slicedToArray(jdate.G(n,r+1,t),3),s=a[0],o=a[1],h=a[2],u=E(new Date(s,o-1,h),i);return e?u:u.endOf(D)},d=(this.$W+(7-n.$fdow))%7;switch(h){case Y:return e?u(1,0):u(0,0,this.$jy+1);case M:return e?u(1,this.$jM):u(0,(this.$jM+1)%12,this.$jy+parseInt((this.$jM+1)/12,10));case W:return u(e?this.$jD-d:this.$jD+(6-d),this.$jM);default:return $.bind(this)(t,r)}},i.$set=function(t,r){var n=this;if(!a(this))return j.bind(this)(t,r);var i=function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.$jy,e=_slicedToArray(jdate.G(i,r+1,t),3),a=e[0],s=e[1],o=e[2];return n.$d.setDate(o),n.$d.setMonth(s-1),n.$d.setFullYear(a),n};switch(s(t)){case DATE:case D:i(r,this.$jM);break;case M:i(this.$jD,r);break;case Y:i(this.$jD,this.$jM,r);break;default:return j.bind(this)(t,r)}return this.init(),this},i.add=function(t,r){var n=this;if(!a(this))return _.bind(this)(t,r);t=Number(t);var i=!r||1!==r.length&&"ms"!==r?s(r):r;if(["M",M].indexOf(i)>-1){var e=this.$jM+t,o=e<0?-Math.ceil(-e/12):parseInt(e/12,10);return this.add(o,Y).set(M,e-12*o)}if(["y",Y].indexOf(i)>-1)return function(r,i){var e=n.set(DATE,1).set(r,i+t);return e.set(DATE,Math.min(n.$jD,e.daysInMonth()))}(Y,this.$jy);if(["d",D].indexOf(i)>-1){var h=new Date(this.$d);return h.setDate(h.getDate()+t),E(h,this)}return _.bind(this)(t,r)},i.format=function(t,r){var n=this;if(!a(this))return y.bind(this)(t,r);var i=t||FORMAT_DEFAULT,e=(r||this.$locale()).jmonths;return i.replace(REGEX_FORMAT,function(t){if(t.indexOf("[")>-1)return t.replace(/\[|\]/g,"");switch(t){case"YY":return String(n.$jy).slice(-2);case"YYYY":return String(n.$jy);case"M":return String(n.$jM+1);case"MM":return h(n.$jM+1,2,"0");case"MMM":return e[n.$jM].slice(0,3);case"MMMM":return e[n.$jM];case"D":return String(n.$jD);case"DD":return h(n.$jD,2,"0");default:return y.bind(n)(t,r)}})},i.diff=function(t,r,i){if(!a(this))return v.bind(this)(t,r,i);var e=s(r),o=n(t),h=u(this,o);switch(e){case Y:h/=12;break;case M:break;default:return v.bind(this)(t,r,i)}return i?h:d(h)},i.year=function(){return a(this)?this.$jy:m.bind(this)()},i.month=function(){return a(this)?this.$jM:b.bind(this)()},i.date=function(){return a(this)?this.$jD:p.bind(this)()},i.daysInMonth=function(){return a(this)?this.endOf(M).$jD:g.bind(this)()},i.toArray=function(){return a(this)?[this.$jy,this.$jM,this.$jD,this.$H,this.$m,this.$s,this.$ms]:A.bind(this)()},i.clone=function(){return E(this.toDate(),this)}};module.exports=plugin; | ||
"use strict";function _slicedToArray(t,r){return _arrayWithHoles(t)||_iterableToArrayLimit(t,r)||_nonIterableRest()}function _arrayWithHoles(t){if(Array.isArray(t))return t}function _iterableToArrayLimit(t,r){var n=[],i=!0,e=!1,a=void 0;try{for(var s,o=t[Symbol.iterator]();!(i=(s=o.next()).done)&&(n.push(s.value),!r||n.length!==r);i=!0);}catch(t){e=!0,a=t}finally{try{i||null==o.return||o.return()}finally{if(e)throw a}}return n}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var $floor=Math.floor;function mod(t,r){return t-r*$floor(t/r)}function lg(t){return t%4==0&&!(t%100==0&&t%400!=0)}var GE=1721425.5;function g2j(t,r,n){return GE-1+365*(t-1)+$floor((t-1)/4)+-$floor((t-1)/100)+$floor((t-1)/400)+$floor((367*r-362)/12+(r<=2?0:lg(t)?-1:-2)+n)}function j2g(t){var r,n,i,e,a,s,o,h,u,d,f,l;r=$floor(t-.5)+.5,i=$floor((n=r-GE)/146097),e=mod(n,146097),a=$floor(e/36524),s=mod(e,36524),o=$floor(s/1461),h=mod(s,1461),d=400*i+100*a+4*o+(u=$floor(h/365)),4!=a&&4!=u&&d++,f=r-g2j(d,1,1),l=r<g2j(d,3,1)?0:lg(d)?1:2;var c=$floor((12*(f+l)+373)/367);return[d,c,r-g2j(d,c,1)+1]}var PE=1948320.5;function p2j(t,r,n){var i,e;return e=474+mod(i=t-(t>=0?474:473),2820),n+(r<=7?31*(r-1):30*(r-1)+6)+$floor((682*e-110)/2816)+365*(e-1)+1029983*$floor(i/2820)+(PE-1)}function j2p(t){var r,n,i,e,a,s,o,h,u;return i=(t=$floor(t)+.5)-p2j(475,1,1),e=$floor(i/1029983),1029982==(a=mod(i,1029983))?s=2820:(o=$floor(a/366),h=mod(a,366),s=$floor((2134*o+2816*h+2815)/1028522)+o+1),(r=s+2820*e+474)<=0&&r--,[r,n=(u=t-p2j(r,1,1)+1)<=186?Math.ceil(u/31):Math.ceil((u-6)/30),t-p2j(r,n,1)+1]}var jdate={J:function(t,r,n){return j2p(g2j(t,r,n))},G:function(t,r,n){return j2g(p2j(t,r,n))}},REGEX_PARSE=/^(\d{4})[-\/]?(\d{1,2})[-\/]?(\d{0,2})(.*)?$/,REGEX_FORMAT=/\[.*?\]|jY{2,4}|jM{1,4}|jD{1,2}|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,DATE="date",D="day",M="month",Y="year",W="week",FORMAT_DEFAULT="YYYY-MM-DDTHH:mm:ssZ",fa={name:"fa",weekdays:"یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه".split("_"),months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),jmonths:"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_"),ordinal:function(t){return t},relativeTime:{future:"در %s ثانیهی آتی",past:"%s پیش",s:"چند ثانیه پیش",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}},plugin=function(t,r,n){var i=r.prototype,e=i.$utils(),a=function(t){return"jalali"===t.$C},s=e.prettyUnit||e.p,o=e.isUndefined||e.u,h=e.padStart||e.s,u=e.monthDiff||e.m,d=e.absFloor||e.a,f=function(t){return function(){var r=t.bind(this).apply(void 0,arguments);return r.$C=this.$C,r.isJalali()&&r.InitJalali(),r}};i.startOf=f(i.startOf),i.endOf=f(i.endOf),i.add=f(i.add),i.subtract=f(i.subtract),i.set=f(i.set);var l=i.parse,c=i.init,$=i.startOf,j=i.$set,_=i.add,y=i.format,v=i.diff,m=i.year,b=i.month,p=i.date,g=i.daysInMonth,A=i.toArray;n.$C="gregory",n.$fdow=6,n.calendar=function(t){return n.$C=t,n},i.calendar=function(t){var r=this.clone();return r.$C=t,r.isJalali()&&r.InitJalali(),r},i.isJalali=function(){return a(this)},n.en.jmonths="Farvardin_Ordibehesht_Khordaad_Tir_Mordaad_Shahrivar_Mehr_Aabaan_Aazar_Dey_Bahman_Esfand".split("_"),n.locale("fa",fa,!0);var E=function(t,r){return n(t,{locale:r.$L,calendar:r.$C})};i.init=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};c.bind(this)(t),this.isJalali()&&this.InitJalali()},i.parse=function(t){var r;if(this.$C=t.calendar||this.$C||n.$C,t.jalali&&"string"==typeof t.date&&/.*[^Z]$/i.test(t.date)&&(r=t.date.match(REGEX_PARSE))){var i=_slicedToArray(jdate.G(parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3]||1,10)),3),e=i[0],a=i[1],s=i[2];t.date="".concat(e,"-").concat(a,"-").concat(s).concat(r[4]||"")}return l.bind(this)(t)},i.InitJalali=function(){var t=_slicedToArray(jdate.J(this.$y,this.$M+1,this.$D),3),r=t[0],n=t[1],i=t[2];this.$jy=r,this.$jM=n-1,this.$jD=i},i.startOf=function(t,r){var i=this;if(!a(this))return $.bind(this)(t,r);var e=!!o(r)||r,h=s(t),u=function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.$jy,a=_slicedToArray(jdate.G(n,r+1,t),3),s=a[0],o=a[1],h=a[2],u=E(new Date(s,o-1,h),i);return e?u:u.endOf(D)},d=(this.$W+(7-n.$fdow))%7;switch(h){case Y:return e?u(1,0):u(0,0,this.$jy+1);case M:return e?u(1,this.$jM):u(0,(this.$jM+1)%12,this.$jy+parseInt((this.$jM+1)/12,10));case W:return u(e?this.$jD-d:this.$jD+(6-d),this.$jM);default:return $.bind(this)(t,r)}},i.$set=function(t,r){var n=this;if(!a(this))return j.bind(this)(t,r);var i=function(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.$jy,e=_slicedToArray(jdate.G(i,r+1,t),3),a=e[0],s=e[1],o=e[2];return n.$d.setDate(o),n.$d.setMonth(s-1),n.$d.setFullYear(a),n};switch(s(t)){case DATE:case D:i(r,this.$jM);break;case M:i(this.$jD,r);break;case Y:i(this.$jD,this.$jM,r);break;default:return j.bind(this)(t,r)}return this.init(),this},i.add=function(t,r){var n=this;if(!a(this))return _.bind(this)(t,r);t=Number(t);var i=!r||1!==r.length&&"ms"!==r?s(r):r;if(["M",M].indexOf(i)>-1){var e=this.$jM+t,o=e<0?-Math.ceil(-e/12):parseInt(e/12,10);return this.add(o,Y).set(M,e-12*o)}if(["y",Y].indexOf(i)>-1)return function(r,i){var e=n.set(DATE,1).set(r,i+t);return e.set(DATE,Math.min(n.$jD,e.daysInMonth()))}(Y,this.$jy);if(["d",D].indexOf(i)>-1){var h=new Date(this.$d);return h.setDate(h.getDate()+t),E(h,this)}return _.bind(this)(t,r)},i.format=function(t,r){var n=this;if(!a(this))return y.bind(this)(t,r);var i=t||FORMAT_DEFAULT,e=(r||this.$locale()).jmonths;return i.replace(REGEX_FORMAT,function(t){if(t.indexOf("[")>-1)return t.replace(/\[|\]/g,"");switch(t){case"YY":return String(n.$jy).slice(-2);case"YYYY":return String(n.$jy);case"M":return String(n.$jM+1);case"MM":return h(n.$jM+1,2,"0");case"MMM":return e[n.$jM].slice(0,3);case"MMMM":return e[n.$jM];case"D":return String(n.$jD);case"DD":return h(n.$jD,2,"0");default:return y.bind(n)(t,r)}})},i.diff=function(t,r,i){if(!a(this))return v.bind(this)(t,r,i);var e=s(r),o=n(t),h=u(this,o);switch(e){case Y:h/=12;break;case M:break;default:return v.bind(this)(t,r,i)}return i?h:d(h)},i.year=function(){return a(this)?this.$jy:m.bind(this)()},i.month=function(){return a(this)?this.$jM:b.bind(this)()},i.date=function(){return a(this)?this.$jD:p.bind(this)()},i.daysInMonth=function(){return a(this)?this.endOf(M).$jD:g.bind(this)()},A&&(i.toArray=function(){return a(this)?[this.$jy,this.$jM,this.$jD,this.$H,this.$m,this.$s,this.$ms]:A.bind(this)()}),i.clone=function(){return E(this.toDate(),this)}};module.exports=plugin; | ||
//# sourceMappingURL=jalaliday.cjs.min.js.map |
@@ -181,7 +181,7 @@ function _slicedToArray(arr, i) { | ||
var $prettyUnit = U.prettyUnit; | ||
var $isUndefined = U.isUndefined; | ||
var $padStart = U.padStart; | ||
var $monthDiff = U.monthDiff; | ||
var $absFloor = U.absFloor; | ||
var $prettyUnit = U.prettyUnit || U.p; | ||
var $isUndefined = U.isUndefined || U.u; | ||
var $padStart = U.padStart || U.s; | ||
var $monthDiff = U.monthDiff || U.m; | ||
var $absFloor = U.absFloor || U.a; | ||
@@ -266,4 +266,4 @@ var wrapperOfTruth = function wrapperOfTruth(action) { | ||
if (cfg.jalali && typeof cfg.date === 'string' && /.*[^Z]$/i.test(cfg.date) && ( // looking for a better way | ||
reg = cfg.date.match(REGEX_PARSE))) { | ||
if (cfg.jalali && typeof cfg.date === 'string' && /.*[^Z]$/i.test(cfg.date) // looking for a better way | ||
&& (reg = cfg.date.match(REGEX_PARSE))) { | ||
// 1397-08-08 or 13970808 | ||
@@ -521,11 +521,18 @@ var _jdate$G = jdate.G(parseInt(reg[1], 10), parseInt(reg[2], 10), parseInt(reg[3] || 1, 10)), | ||
}; | ||
/** | ||
* toArray function moved to official plugin | ||
* Check function existence before override | ||
*/ | ||
proto.toArray = function () { | ||
if (!$isJalali(this)) { | ||
return oldToArray.bind(this)(); | ||
} | ||
return [this.$jy, this.$jM, this.$jD, this.$H, this.$m, this.$s, this.$ms]; | ||
}; | ||
if (oldToArray) { | ||
proto.toArray = function () { | ||
if (!$isJalali(this)) { | ||
return oldToArray.bind(this)(); | ||
} | ||
return [this.$jy, this.$jM, this.$jD, this.$H, this.$m, this.$s, this.$ms]; | ||
}; | ||
} | ||
proto.clone = function () { | ||
@@ -532,0 +539,0 @@ return wrapper(this.toDate(), this); |
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.jalaliday=n()}(this,function(){"use strict";function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var i=[],r=!0,e=!1,a=void 0;try{for(var s,h=t[Symbol.iterator]();!(r=(s=h.next()).done)&&(i.push(s.value),!n||i.length!==n);r=!0);}catch(t){e=!0,a=t}finally{try{r||null==h.return||h.return()}finally{if(e)throw a}}return i}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var n=Math.floor;function i(t,i){return t-i*n(t/i)}function r(t){return t%4==0&&!(t%100==0&&t%400!=0)}var e=1721425.5;function a(t,i,a){return e-1+365*(t-1)+n((t-1)/4)+-n((t-1)/100)+n((t-1)/400)+n((367*i-362)/12+(i<=2?0:r(t)?-1:-2)+a)}var s=1948320.5;function h(t,r,e){var a,h;return h=474+i(a=t-(t>=0?474:473),2820),e+(r<=7?31*(r-1):30*(r-1)+6)+n((682*h-110)/2816)+365*(h-1)+1029983*n(a/2820)+(s-1)}var u=function(t,r,e){return s=a(t,r,e),o=(s=n(s)+.5)-h(475,1,1),f=n(o/1029983),1029982==(c=i(o,1029983))?l=2820:($=n(c/366),j=i(c,366),l=n((2134*$+2816*j+2815)/1028522)+$+1),(u=l+2820*f+474)<=0&&u--,[u,d=(M=s-h(u,1,1)+1)<=186?Math.ceil(M/31):Math.ceil((M-6)/30),s-h(u,d,1)+1];var s,u,d,o,f,c,l,$,j,M},d=function(t,s,u){return function(t){var s,h,u,d,o,f,c,l,$,j,M,v;s=n(t-.5)+.5,u=n((h=s-e)/146097),d=i(h,146097),o=n(d/36524),f=i(d,36524),c=n(f/1461),l=i(f,1461),j=400*u+100*o+4*c+($=n(l/365)),4!=o&&4!=$&&j++,M=s-a(j,1,1),v=s<a(j,3,1)?0:r(j)?1:2;var y=n((12*(M+v)+373)/367);return[j,y,s-a(j,y,1)+1]}(h(t,s,u))},o=/^(\d{4})[-/]?(\d{1,2})[-/]?(\d{0,2})(.*)?$/,f=/\[.*?\]|jY{2,4}|jM{1,4}|jD{1,2}|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c="day",l="month",$="year",j={name:"fa",weekdays:"یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه".split("_"),months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),jmonths:"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_"),ordinal:function(t){return t},relativeTime:{future:"در %s ثانیهی آتی",past:"%s پیش",s:"چند ثانیه پیش",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return function(n,i,r){var e=i.prototype,a=e.$utils(),s=function(t){return"jalali"===t.$C},h=a.prettyUnit,M=a.isUndefined,v=a.padStart,y=a.monthDiff,_=a.absFloor,b=function(t){return function(){var n=t.bind(this).apply(void 0,arguments);return n.$C=this.$C,n.isJalali()&&n.InitJalali(),n}};e.startOf=b(e.startOf),e.endOf=b(e.endOf),e.add=b(e.add),e.subtract=b(e.subtract),e.set=b(e.set);var m=e.parse,p=e.init,D=e.startOf,g=e.$set,w=e.add,I=e.format,O=e.diff,Y=e.year,C=e.month,S=e.date,J=e.daysInMonth,k=e.toArray;r.$C="gregory",r.$fdow=6,r.calendar=function(t){return r.$C=t,r},e.calendar=function(t){var n=this.clone();return n.$C=t,n.isJalali()&&n.InitJalali(),n},e.isJalali=function(){return s(this)},r.en.jmonths="Farvardin_Ordibehesht_Khordaad_Tir_Mordaad_Shahrivar_Mehr_Aabaan_Aazar_Dey_Bahman_Esfand".split("_"),r.locale("fa",j,!0);var x=function(t,n){return r(t,{locale:n.$L,calendar:n.$C})};e.init=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p.bind(this)(t),this.isJalali()&&this.InitJalali()},e.parse=function(n){var i;if(this.$C=n.calendar||this.$C||r.$C,n.jalali&&"string"==typeof n.date&&/.*[^Z]$/i.test(n.date)&&(i=n.date.match(o))){var e=t(d(parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3]||1,10)),3),a=e[0],s=e[1],h=e[2];n.date="".concat(a,"-").concat(s,"-").concat(h).concat(i[4]||"")}return m.bind(this)(n)},e.InitJalali=function(){var n=t(u(this.$y,this.$M+1,this.$D),3),i=n[0],r=n[1],e=n[2];this.$jy=i,this.$jM=r-1,this.$jD=e},e.startOf=function(n,i){var e=this;if(!s(this))return D.bind(this)(n,i);var a=!!M(i)||i,u=h(n),o=function(n,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.$jy,s=t(d(r,i+1,n),3),h=s[0],u=s[1],o=s[2],f=x(new Date(h,u-1,o),e);return a?f:f.endOf(c)},f=(this.$W+(7-r.$fdow))%7;switch(u){case $:return a?o(1,0):o(0,0,this.$jy+1);case l:return a?o(1,this.$jM):o(0,(this.$jM+1)%12,this.$jy+parseInt((this.$jM+1)/12,10));case"week":return o(a?this.$jD-f:this.$jD+(6-f),this.$jM);default:return D.bind(this)(n,i)}},e.$set=function(n,i){var r=this;if(!s(this))return g.bind(this)(n,i);var e=function(n,i){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r.$jy,a=t(d(e,i+1,n),3),s=a[0],h=a[1],u=a[2];return r.$d.setDate(u),r.$d.setMonth(h-1),r.$d.setFullYear(s),r};switch(h(n)){case"date":case c:e(i,this.$jM);break;case l:e(this.$jD,i);break;case $:e(this.$jD,this.$jM,i);break;default:return g.bind(this)(n,i)}return this.init(),this},e.add=function(t,n){var i=this;if(!s(this))return w.bind(this)(t,n);t=Number(t);var r=!n||1!==n.length&&"ms"!==n?h(n):n;if(["M",l].indexOf(r)>-1){var e=this.$jM+t,a=e<0?-Math.ceil(-e/12):parseInt(e/12,10);return this.add(a,$).set(l,e-12*a)}if(["y",$].indexOf(r)>-1)return function(n,r){var e=i.set("date",1).set(n,r+t);return e.set("date",Math.min(i.$jD,e.daysInMonth()))}($,this.$jy);if(["d",c].indexOf(r)>-1){var u=new Date(this.$d);return u.setDate(u.getDate()+t),x(u,this)}return w.bind(this)(t,n)},e.format=function(t,n){var i=this;if(!s(this))return I.bind(this)(t,n);var r=t||"YYYY-MM-DDTHH:mm:ssZ",e=(n||this.$locale()).jmonths;return r.replace(f,function(t){if(t.indexOf("[")>-1)return t.replace(/\[|\]/g,"");switch(t){case"YY":return String(i.$jy).slice(-2);case"YYYY":return String(i.$jy);case"M":return String(i.$jM+1);case"MM":return v(i.$jM+1,2,"0");case"MMM":return e[i.$jM].slice(0,3);case"MMMM":return e[i.$jM];case"D":return String(i.$jD);case"DD":return v(i.$jD,2,"0");default:return I.bind(i)(t,n)}})},e.diff=function(t,n,i){if(!s(this))return O.bind(this)(t,n,i);var e=h(n),a=r(t),u=y(this,a);switch(e){case $:u/=12;break;case l:break;default:return O.bind(this)(t,n,i)}return i?u:_(u)},e.year=function(){return s(this)?this.$jy:Y.bind(this)()},e.month=function(){return s(this)?this.$jM:C.bind(this)()},e.date=function(){return s(this)?this.$jD:S.bind(this)()},e.daysInMonth=function(){return s(this)?this.endOf(l).$jD:J.bind(this)()},e.toArray=function(){return s(this)?[this.$jy,this.$jM,this.$jD,this.$H,this.$m,this.$s,this.$ms]:k.bind(this)()},e.clone=function(){return x(this.toDate(),this)}}}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.jalaliday=n()}(this,function(){"use strict";function t(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){var i=[],r=!0,e=!1,a=void 0;try{for(var s,h=t[Symbol.iterator]();!(r=(s=h.next()).done)&&(i.push(s.value),!n||i.length!==n);r=!0);}catch(t){e=!0,a=t}finally{try{r||null==h.return||h.return()}finally{if(e)throw a}}return i}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var n=Math.floor;function i(t,i){return t-i*n(t/i)}function r(t){return t%4==0&&!(t%100==0&&t%400!=0)}var e=1721425.5;function a(t,i,a){return e-1+365*(t-1)+n((t-1)/4)+-n((t-1)/100)+n((t-1)/400)+n((367*i-362)/12+(i<=2?0:r(t)?-1:-2)+a)}var s=1948320.5;function h(t,r,e){var a,h;return h=474+i(a=t-(t>=0?474:473),2820),e+(r<=7?31*(r-1):30*(r-1)+6)+n((682*h-110)/2816)+365*(h-1)+1029983*n(a/2820)+(s-1)}var u=function(t,r,e){return s=a(t,r,e),o=(s=n(s)+.5)-h(475,1,1),f=n(o/1029983),1029982==(c=i(o,1029983))?l=2820:($=n(c/366),j=i(c,366),l=n((2134*$+2816*j+2815)/1028522)+$+1),(u=l+2820*f+474)<=0&&u--,[u,d=(M=s-h(u,1,1)+1)<=186?Math.ceil(M/31):Math.ceil((M-6)/30),s-h(u,d,1)+1];var s,u,d,o,f,c,l,$,j,M},d=function(t,s,u){return function(t){var s,h,u,d,o,f,c,l,$,j,M,v;s=n(t-.5)+.5,u=n((h=s-e)/146097),d=i(h,146097),o=n(d/36524),f=i(d,36524),c=n(f/1461),l=i(f,1461),j=400*u+100*o+4*c+($=n(l/365)),4!=o&&4!=$&&j++,M=s-a(j,1,1),v=s<a(j,3,1)?0:r(j)?1:2;var y=n((12*(M+v)+373)/367);return[j,y,s-a(j,y,1)+1]}(h(t,s,u))},o=/^(\d{4})[-\/]?(\d{1,2})[-\/]?(\d{0,2})(.*)?$/,f=/\[.*?\]|jY{2,4}|jM{1,4}|jD{1,2}|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c="day",l="month",$="year",j={name:"fa",weekdays:"یکشنبه_دوشنبه_سهشنبه_چهارشنبه_پنجشنبه_جمعه_شنبه".split("_"),months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),jmonths:"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_"),ordinal:function(t){return t},relativeTime:{future:"در %s ثانیهی آتی",past:"%s پیش",s:"چند ثانیه پیش",m:"یک دقیقه",mm:"%d دقیقه",h:"یک ساعت",hh:"%d ساعت",d:"یک روز",dd:"%d روز",M:"یک ماه",MM:"%d ماه",y:"یک سال",yy:"%d سال"}};return function(n,i,r){var e=i.prototype,a=e.$utils(),s=function(t){return"jalali"===t.$C},h=a.prettyUnit||a.p,M=a.isUndefined||a.u,v=a.padStart||a.s,y=a.monthDiff||a.m,_=a.absFloor||a.a,b=function(t){return function(){var n=t.bind(this).apply(void 0,arguments);return n.$C=this.$C,n.isJalali()&&n.InitJalali(),n}};e.startOf=b(e.startOf),e.endOf=b(e.endOf),e.add=b(e.add),e.subtract=b(e.subtract),e.set=b(e.set);var m=e.parse,p=e.init,D=e.startOf,g=e.$set,w=e.add,I=e.format,O=e.diff,Y=e.year,C=e.month,S=e.date,J=e.daysInMonth,k=e.toArray;r.$C="gregory",r.$fdow=6,r.calendar=function(t){return r.$C=t,r},e.calendar=function(t){var n=this.clone();return n.$C=t,n.isJalali()&&n.InitJalali(),n},e.isJalali=function(){return s(this)},r.en.jmonths="Farvardin_Ordibehesht_Khordaad_Tir_Mordaad_Shahrivar_Mehr_Aabaan_Aazar_Dey_Bahman_Esfand".split("_"),r.locale("fa",j,!0);var x=function(t,n){return r(t,{locale:n.$L,calendar:n.$C})};e.init=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};p.bind(this)(t),this.isJalali()&&this.InitJalali()},e.parse=function(n){var i;if(this.$C=n.calendar||this.$C||r.$C,n.jalali&&"string"==typeof n.date&&/.*[^Z]$/i.test(n.date)&&(i=n.date.match(o))){var e=t(d(parseInt(i[1],10),parseInt(i[2],10),parseInt(i[3]||1,10)),3),a=e[0],s=e[1],h=e[2];n.date="".concat(a,"-").concat(s,"-").concat(h).concat(i[4]||"")}return m.bind(this)(n)},e.InitJalali=function(){var n=t(u(this.$y,this.$M+1,this.$D),3),i=n[0],r=n[1],e=n[2];this.$jy=i,this.$jM=r-1,this.$jD=e},e.startOf=function(n,i){var e=this;if(!s(this))return D.bind(this)(n,i);var a=!!M(i)||i,u=h(n),o=function(n,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.$jy,s=t(d(r,i+1,n),3),h=s[0],u=s[1],o=s[2],f=x(new Date(h,u-1,o),e);return a?f:f.endOf(c)},f=(this.$W+(7-r.$fdow))%7;switch(u){case $:return a?o(1,0):o(0,0,this.$jy+1);case l:return a?o(1,this.$jM):o(0,(this.$jM+1)%12,this.$jy+parseInt((this.$jM+1)/12,10));case"week":return o(a?this.$jD-f:this.$jD+(6-f),this.$jM);default:return D.bind(this)(n,i)}},e.$set=function(n,i){var r=this;if(!s(this))return g.bind(this)(n,i);var e=function(n,i){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r.$jy,a=t(d(e,i+1,n),3),s=a[0],h=a[1],u=a[2];return r.$d.setDate(u),r.$d.setMonth(h-1),r.$d.setFullYear(s),r};switch(h(n)){case"date":case c:e(i,this.$jM);break;case l:e(this.$jD,i);break;case $:e(this.$jD,this.$jM,i);break;default:return g.bind(this)(n,i)}return this.init(),this},e.add=function(t,n){var i=this;if(!s(this))return w.bind(this)(t,n);t=Number(t);var r=!n||1!==n.length&&"ms"!==n?h(n):n;if(["M",l].indexOf(r)>-1){var e=this.$jM+t,a=e<0?-Math.ceil(-e/12):parseInt(e/12,10);return this.add(a,$).set(l,e-12*a)}if(["y",$].indexOf(r)>-1)return function(n,r){var e=i.set("date",1).set(n,r+t);return e.set("date",Math.min(i.$jD,e.daysInMonth()))}($,this.$jy);if(["d",c].indexOf(r)>-1){var u=new Date(this.$d);return u.setDate(u.getDate()+t),x(u,this)}return w.bind(this)(t,n)},e.format=function(t,n){var i=this;if(!s(this))return I.bind(this)(t,n);var r=t||"YYYY-MM-DDTHH:mm:ssZ",e=(n||this.$locale()).jmonths;return r.replace(f,function(t){if(t.indexOf("[")>-1)return t.replace(/\[|\]/g,"");switch(t){case"YY":return String(i.$jy).slice(-2);case"YYYY":return String(i.$jy);case"M":return String(i.$jM+1);case"MM":return v(i.$jM+1,2,"0");case"MMM":return e[i.$jM].slice(0,3);case"MMMM":return e[i.$jM];case"D":return String(i.$jD);case"DD":return v(i.$jD,2,"0");default:return I.bind(i)(t,n)}})},e.diff=function(t,n,i){if(!s(this))return O.bind(this)(t,n,i);var e=h(n),a=r(t),u=y(this,a);switch(e){case $:u/=12;break;case l:break;default:return O.bind(this)(t,n,i)}return i?u:_(u)},e.year=function(){return s(this)?this.$jy:Y.bind(this)()},e.month=function(){return s(this)?this.$jM:C.bind(this)()},e.date=function(){return s(this)?this.$jD:S.bind(this)()},e.daysInMonth=function(){return s(this)?this.endOf(l).$jD:J.bind(this)()},k&&(e.toArray=function(){return s(this)?[this.$jy,this.$jM,this.$jD,this.$H,this.$m,this.$s,this.$ms]:k.bind(this)()}),e.clone=function(){return x(this.toDate(),this)}}}); | ||
//# sourceMappingURL=jalaliday.min.js.map |
{ | ||
"name": "jalaliday", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Persian (Jalali, Khorshidi) Plugin for Day.js", | ||
@@ -50,3 +50,3 @@ "main": "dist/jalaliday.cjs.min.js", | ||
"@babel/preset-env": "^7.3.4", | ||
"bili": "^4.4.0", | ||
"bili": "^3.4.2", | ||
"codecov": "^3.2.0", | ||
@@ -53,0 +53,0 @@ "eslint": "^5.15.1", |
@@ -274,7 +274,13 @@ import jdate from './calendar' | ||
proto.toArray = function () { | ||
if (!$isJalali(this)) { | ||
return oldToArray.bind(this)() | ||
/** | ||
* toArray function moved to official plugin | ||
* Check function existence before override | ||
*/ | ||
if (oldToArray) { | ||
proto.toArray = function () { | ||
if (!$isJalali(this)) { | ||
return oldToArray.bind(this)() | ||
} | ||
return [this.$jy, this.$jM, this.$jD, this.$H, this.$m, this.$s, this.$ms] | ||
} | ||
return [this.$jy, this.$jM, this.$jD, this.$H, this.$m, this.$s, this.$ms] | ||
} | ||
@@ -281,0 +287,0 @@ |
import MockDate from 'mockdate' | ||
import dayjs from 'dayjs' | ||
import toArray from 'dayjs/plugin/toArray' | ||
import jalali from '../src' | ||
dayjs.extend(toArray) | ||
dayjs.extend(jalali) | ||
@@ -6,0 +8,0 @@ dayjs.calendar('jalali') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112765
27
1365