1
0

moment-jalali.min.js 13 KB

1
  1. !function(){function t(e){var n=t.modules[e];if(!n)throw new Error('failed to require "'+e+'"');return"exports"in n||"function"!=typeof n.definition||(n.client=n.component=!0,n.definition.call(this,n.exports={},n),delete n.definition),n.exports}t.modules={moment:{exports:moment}},t.register=function(e,n){t.modules[e]={definition:n}},t.define=function(e,n){t.modules[e]={exports:n}},t.register("jalaali-js",(function(t,e){function n(t){return 0===a(t).leap}function r(t,e){return e<=6?31:e<=11||n(t)?30:29}function a(t){var e,n,r,a,i,s,o=[-61,9,38,199,426,686,756,818,1111,1181,1210,1635,2060,2097,2192,2262,2324,2394,2456,3178],u=o.length,f=t+621,l=-14,j=o[0];if(t<j||t>=o[u-1])throw new Error("Invalid Jalaali year "+t);for(s=1;s<u&&(n=(e=o[s])-j,!(t<e));s+=1)l=l+8*c(n,33)+c(h(n,33),4),j=e;return l=l+8*c(i=t-j,33)+c(h(i,33)+3,4),4===h(n,33)&&n-i==4&&(l+=1),a=20+l-(c(f,4)-c(3*(c(f,100)+1),4)-150),n-i<6&&(i=i-n+33*c(n+4,33)),-1===(r=h(h(i+1,33)-1,4))&&(r=4),{leap:r,gy:f,march:a}}function i(t,e,n){var r=a(t);return o(r.gy,3,r.march)+31*(e-1)-c(e,7)*(e-7)+n-1}function s(t){var e,n=u(t).gy,r=n-621,i=a(r);if((e=t-o(n,3,i.march))>=0){if(e<=185)return{jy:r,jm:1+c(e,31),jd:h(e,31)+1};e-=186}else r-=1,e+=179,1===i.leap&&(e+=1);return{jy:r,jm:7+c(e,30),jd:h(e,30)+1}}function o(t,e,n){var r=c(1461*(t+c(e-8,6)+100100),4)+c(153*h(e+9,12)+2,5)+n-34840408;return r=r-c(3*c(t+100100+c(e-8,6),100),4)+752}function u(t){var e,n,r,a;return e=(e=4*t+139361631)+4*c(3*c(4*t+183187720,146097),4)-3908,n=5*c(h(e,1461),4)+308,r=c(h(n,153),5)+1,a=h(c(n,153),12)+1,{gy:c(e,1461)-100100+c(8-a,6),gm:a,gd:r}}function c(t,e){return~~(t/e)}function h(t,e){return t-~~(t/e)*e}e.exports={toJalaali:function(t,e,n){"[object Date]"===Object.prototype.toString.call(t)&&(n=t.getDate(),e=t.getMonth()+1,t=t.getFullYear());return s(o(t,e,n))},toGregorian:function(t,e,n){return u(i(t,e,n))},isValidJalaaliDate:function(t,e,n){return t>=-61&&t<=3177&&e>=1&&e<=12&&n>=1&&n<=r(t,e)},isLeapJalaaliYear:n,jalaaliMonthLength:r,jalCal:a,j2d:i,d2j:s,g2d:o,d2g:u}})),t.register("moment-jalaali",(function(e,n){n.exports=W;var r,a=t("moment"),i=t("jalaali-js"),s=/(\[[^\[]*\])|(\\)?j(Mo|MM?M?M?|Do|DDDo|DD?D?D?|w[o|w]?|YYYYY|YYYY|YY|gg(ggg?)?|)|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|SS?S?|X|zz?|ZZ?|.)/g,o=/(\[[^\[]*\])|(\\)?(LTS?|LL?L?L?|l{1,4})/g,u=/\d\d?/,c=/\d{1,3}/,h=/\d{3}/,f=/\d{1,4}/,l=/[+\-]?\d{1,6}/,j=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,_=/Z|[\+\-]\d\d:?\d\d/i,d=/T/i,D=/[\+\-]?\d+(\.\d{1,3})?/,M={1:"۱",2:"۲",3:"۳",4:"۴",5:"۵",6:"۶",7:"۷",8:"۸",9:"۹",0:"۰"},Y={"۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","۰":"0"},m={jm:"jmonth",jmonths:"jmonth",jy:"jyear",jyears:"jyear"},g={},p="DDD w M D".split(" "),y="M D w".split(" "),v={jM:function(){return this.jMonth()+1},jMMM:function(t){return this.localeData().jMonthsShort(this,t)},jMMMM:function(t){return this.localeData().jMonths(this,t)},jD:function(){return this.jDate()},jDDD:function(){return this.jDayOfYear()},jw:function(){return this.jWeek()},jYY:function(){return S(this.jYear()%100,2)},jYYYY:function(){return S(this.jYear(),4)},jYYYYY:function(){return S(this.jYear(),5)},jgg:function(){return S(this.jWeekYear()%100,2)},jgggg:function(){return this.jWeekYear()},jggggg:function(){return S(this.jWeekYear(),5)}};function w(t,e){return function(n){return S(t.call(this,n),e)}}function L(t,e){return function(n){return this.localeData().ordinal(t.call(this,n),e)}}function O(t,e){var n;for(n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function S(t,e){for(var n=t+"";n.length<e;)n="0"+n;return n}function k(t){if(t){var e=t.toLowerCase();t=m[e]||e}return t}function N(t,e,n,r){var a=t._d;isNaN(e)&&(t._isValid=!1),t._isUTC?t._d=new Date(Date.UTC(e,n,r,a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds(),a.getUTCMilliseconds())):t._d=new Date(e,n,r,a.getHours(),a.getMinutes(),a.getSeconds(),a.getMilliseconds())}function F(t){function e(){}return e.prototype=t,new e}function T(t,e){switch(t){case"jDDDD":return h;case"jYYYY":return f;case"jYYYYY":return l;case"jDDD":return c;case"jMMM":case"jMMMM":return j;case"jMM":case"jDD":case"jYY":case"jM":case"jD":return u;case"DDDD":return h;case"YYYY":return f;case"YYYYY":return l;case"S":case"SS":case"SSS":case"DDD":return c;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return j;case"a":case"A":return a.localeData(e._l)._meridiemParse;case"X":return D;case"Z":case"ZZ":return _;case"T":return d;case"MM":case"DD":case"YY":case"HH":case"hh":case"mm":case"ss":case"M":case"D":case"d":case"H":case"h":case"m":case"s":return u;default:return new RegExp(t.replace("\\",""))}}function b(t,e,n){var r,i=n._a;switch(t){case"jM":case"jMM":i[1]=null==e?0:~~e-1;break;case"jMMM":case"jMMMM":null!=(r=a.localeData(n._l).jMonthsParse(e))?i[1]=r:n._isValid=!1;break;case"jD":case"jDD":case"jDDD":case"jDDDD":null!=e&&(i[2]=~~e);break;case"jYY":i[0]=~~e+(~~e>47?1300:1400);break;case"jYYYY":case"jYYYYY":i[0]=~~e}null==e&&(n._isValid=!1)}function x(t){var e,n,r,a=t._f.match(s),i=t._i+"",o=a.length;for(t._a=[],e=0;e<o;e+=1)(r=(T(n=a[e],t).exec(i)||[])[0])&&(i=i.slice(i.indexOf(r)+r.length)),v[n]&&b(n,r,t);return i&&(t._il=i),function(t){var e,n,r=t._a[0],a=t._a[1],i=t._a[2];return null==r&&null==a&&null==i?[0,0,1]:(r=null!=r?r:0,a=null!=a?a:0,((i=null!=i?i:1)<1||i>W.jDaysInMonth(r,a)||a<0||a>11)&&(t._isValid=!1),n=A((e=E(r,a,i)).gy,e.gm,e.gd),isNaN(e.gy)&&(t._isValid=!1),t._jDiff=0,~~n.jy!==r&&(t._jDiff+=1),~~n.jm!==a&&(t._jDiff+=1),~~n.jd!==i&&(t._jDiff+=1),[e.gy,e.gm,e.gd])}(t)}function P(t,e,n){var r,a=n-e,i=n-t.day();return i>a&&(i-=7),i<a-7&&(i+=7),r=W(t).add(i,"d"),{week:Math.ceil(r.jDayOfYear()/7),year:r.jYear()}}!function(){for(var t;p.length;)t=p.pop(),v["j"+t+"o"]=L(v["j"+t],t);for(;y.length;)t=y.pop(),v["j"+t+t]=w(v["j"+t],2);v.jDDDD=w(v.jDDD,3)}(),O((r=a.localeData(),Object.getPrototypeOf?Object.getPrototypeOf(r):"".__proto__?r.__proto__:r.constructor.prototype),{_jMonths:["Farvardin","Ordibehesht","Khordaad","Tir","Amordaad","Shahrivar","Mehr","Aabaan","Aazar","Dey","Bahman","Esfand"],jMonths:function(t){return this._jMonths[t.jMonth()]},_jMonthsShort:["Far","Ord","Kho","Tir","Amo","Sha","Meh","Aab","Aaz","Dey","Bah","Esf"],jMonthsShort:function(t){return this._jMonthsShort[t.jMonth()]},jMonthsParse:function(t){var e,n,r;for(this._jMonthsParse||(this._jMonthsParse=[]),e=0;e<12;e+=1)if(this._jMonthsParse[e]||(n=W([2e3,(2+e)%12,25]),r="^"+this.jMonths(n,"")+"|^"+this.jMonthsShort(n,""),this._jMonthsParse[e]=new RegExp(r.replace(".",""),"i")),this._jMonthsParse[e].test(t))return e}});function V(t,e,n,r,i){"boolean"==typeof n&&(r=n,n=void 0),e&&"string"==typeof e&&(e=C(e,a));var o,u,c,h={_i:t,_f:e,_l:n,_strict:r,_isUTC:i},f=t,l=e;if(e){if(function(t){return"[object Array]"===Object.prototype.toString.call(t)}(e))return function(t,e){var n,r,a,i,s,o,u=t._f.length;if(0===u)return V(new Date(NaN));for(n=0;n<u;n+=1)r=t._f[n],s=0,(a=V(t._i,r,t._l,t._strict,e)).isValid()&&(s+=a._jDiff,a._il&&(s+=a._il.length),(null==o||s<o)&&(o=s,i=a));return i}(h,i);o=x(h),function(t){var e,n,r,a=t._i+"",i="",o="",u=t._f.match(s),c=u.length;for(e=0;e<c;e+=1)(r=(T(n=u[e],t).exec(a)||[])[0])&&(a=a.slice(a.indexOf(r)+r.length)),v[n]instanceof Function||(o+=n,r&&(i+=r));t._i=i,t._f=o}(h),e="YYYY-MM-DD-"+h._f,t=S(o[0],4)+"-"+S(o[1]+1,2)+"-"+S(o[2],2)+"-"+h._i}return u=i?a.utc(t,e,n,r):a(t,e,n,r),!1===h._isValid&&(u._isValid=!1),u._jDiff=h._jDiff||0,O(c=F(W.fn),u),r&&e&&c.isValid()&&(c._isValid=c.format(l)===f),u._d.getTime()>57724432199999&&(c._isValid=!1),c}function W(t,e,n,r){return V(t,e,n,r,!1)}function C(t,e){for(var n=5,r=function(t){return e.localeData().longDateFormat(t)||t};n>0&&o.test(t);)n-=1,t=t.replace(o,r);return t}function A(t,e,n){try{var r=i.toJalaali(t,e+1,n);return r.jm-=1,r}catch(t){return{jy:NaN,jm:NaN,jd:NaN}}}function E(t,e,n){try{var r=i.toGregorian(t,e+1,n);return r.gm-=1,r}catch(t){return{gy:NaN,gm:NaN,gd:NaN}}}function H(t,e){return~~(t/e)}function G(t,e){return t-~~(t/e)*e}O(W,a),W.fn=F(a.fn),W.utc=function(t,e,n,r){return V(t,e,n,r,!0)},W.unix=function(t){return V(1e3*t)},W.fn.format=function(t){return t&&(t=C(t,this),g[t]||(g[t]=function(t){var e,n=t.match(s),r=n.length;for(e=0;e<r;e+=1)v[n[e]]&&(n[e]=v[n[e]]);return function(a){var i="";for(e=0;e<r;e+=1)i+=n[e]instanceof Function?"["+n[e].call(a,t)+"]":n[e];return i}}(t)),t=g[t](this)),a.fn.format.call(this,t)},W.fn.jYear=function(t){var e,n,r;return"number"==typeof t?(n=A(this.year(),this.month(),this.date()),e=Math.min(n.jd,W.jDaysInMonth(t,n.jm)),N(this,(r=E(t,n.jm,e)).gy,r.gm,r.gd),a.updateOffset(this),this):A(this.year(),this.month(),this.date()).jy},W.fn.jMonth=function(t){var e,n,r;return null!=t?("string"==typeof t&&"number"!=typeof(t=this.localeData().jMonthsParse(t))||(n=A(this.year(),this.month(),this.date()),e=Math.min(n.jd,W.jDaysInMonth(n.jy,t)),this.jYear(n.jy+H(t,12)),(t=G(t,12))<0&&(t+=12,this.jYear(this.jYear()-1)),N(this,(r=E(this.jYear(),t,e)).gy,r.gm,r.gd),a.updateOffset(this)),this):A(this.year(),this.month(),this.date()).jm},W.fn.jDate=function(t){var e,n;return"number"==typeof t?(N(this,(n=E((e=A(this.year(),this.month(),this.date())).jy,e.jm,t)).gy,n.gm,n.gd),a.updateOffset(this),this):A(this.year(),this.month(),this.date()).jd},W.fn.jDayOfYear=function(t){var e=Math.round((W(this).startOf("day")-W(this).startOf("jYear"))/864e5)+1;return null==t?e:this.add(t-e,"d")},W.fn.jWeek=function(t){var e=P(this,this.localeData()._week.dow,this.localeData()._week.doy).week;return null==t?e:this.add(7*(t-e),"d")},W.fn.jWeekYear=function(t){var e=P(this,this.localeData()._week.dow,this.localeData()._week.doy).year;return null==t?e:this.add(t-e,"y")},W.fn.add=function(t,e){var n;return null===e||isNaN(+e)||(n=t,t=e,e=n),"jyear"===(e=k(e))?this.jYear(this.jYear()+t):"jmonth"===e?this.jMonth(this.jMonth()+t):(a.fn.add.call(this,t,e),isNaN(this.jYear())&&(this._isValid=!1)),this},W.fn.subtract=function(t,e){var n;return null===e||isNaN(+e)||(n=t,t=e,e=n),"jyear"===(e=k(e))?this.jYear(this.jYear()-t):"jmonth"===e?this.jMonth(this.jMonth()-t):a.fn.subtract.call(this,t,e),this},W.fn.startOf=function(t){return"jyear"===(t=k(t))||"jmonth"===t?("jyear"===t&&this.jMonth(0),this.jDate(1),this.hours(0),this.minutes(0),this.seconds(0),this.milliseconds(0),this):a.fn.startOf.call(this,t)},W.fn.endOf=function(t){return void 0===(t=k(t))||"milisecond"===t?this:this.startOf(t).add(1,"isoweek"===t?"week":t).subtract(1,"ms")},W.fn.isSame=function(t,e){return"jyear"===(e=k(e))||"jmonth"===e?a.fn.isSame.call(this.startOf(e),t.startOf(e)):a.fn.isSame.call(this,t,e)},W.fn.clone=function(){return W(this)},W.fn.jYears=W.fn.jYear,W.fn.jMonths=W.fn.jMonth,W.fn.jDates=W.fn.jDate,W.fn.jWeeks=W.fn.jWeek,W.jDaysInMonth=function(t,e){return t+=H(e,12),(e=G(e,12))<0&&(e+=12,t-=1),e<6?31:e<11||W.jIsLeapYear(t)?30:29},W.jIsLeapYear=i.isLeapJalaaliYear,W.loadPersian=function(t){var e=!(void 0===t||!t.hasOwnProperty("usePersianDigits"))&&t.usePersianDigits,n=void 0!==t&&t.hasOwnProperty("dialect")?t.dialect:"persian";a.locale("fa"),a.updateLocale("fa",{months:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),monthsShort:"ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر".split("_"),weekdays:{persian:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_آدینه_شنبه".split("_"),"persian-modern":"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_")}[n],weekdaysShort:{persian:"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_آدینه_شنبه".split("_"),"persian-modern":"یک‌شنبه_دوشنبه_سه‌شنبه_چهارشنبه_پنج‌شنبه_جمعه_شنبه".split("_")}[n],weekdaysMin:{persian:"ی_د_س_چ_پ_آ_ش".split("_"),"persian-modern":"ی_د_س_چ_پ_ج_ش".split("_")}[n],longDateFormat:{LT:"HH:mm",L:"jYYYY/jMM/jDD",LL:"jD jMMMM jYYYY",LLL:"jD jMMMM jYYYY LT",LLLL:"dddd، jD jMMMM jYYYY LT"},calendar:{sameDay:"[امروز ساعت] LT",nextDay:"[فردا ساعت] LT",nextWeek:"dddd [ساعت] LT",lastDay:"[دیروز ساعت] LT",lastWeek:"dddd [ی پیش ساعت] LT",sameElse:"L"},relativeTime:{future:"در %s",past:"%s پیش",s:"چند ثانیه",m:"1 دقیقه",mm:"%d دقیقه",h:"1 ساعت",hh:"%d ساعت",d:"1 روز",dd:"%d روز",M:"1 ماه",MM:"%d ماه",y:"1 سال",yy:"%d سال"},preparse:function(t){return e?t.replace(/[۰-۹]/g,(function(t){return Y[t]})).replace(/،/g,","):t},postformat:function(t){return e?t.replace(/\d/g,(function(t){return M[t]})).replace(/,/g,"،"):t},ordinal:"%dم",week:{dow:6,doy:12},meridiem:function(t){return t<12?"ق.ظ":"ب.ظ"},jMonths:{persian:"فروردین_اردیبهشت_خرداد_تیر_امرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_"),"persian-modern":"فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند".split("_")}[n],jMonthsShort:{persian:"فرو_ارد_خرد_تیر_امر_شهر_مهر_آبا_آذر_دی_بهم_اسف".split("_"),"persian-modern":"فرو_ارد_خرد_تیر_مرد_شهر_مهر_آبا_آذر_دی_بهم_اسف".split("_")}[n]})},W.jConvert={toJalaali:A,toGregorian:E}})),"object"==typeof exports?module.exports=t("moment-jalaali"):"function"==typeof define&&define.amd?define([],(function(){return t("moment-jalaali")})):this.moment=t("moment-jalaali")}();