1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
36 KiB
JavaScript

2 years ago
/*!
*
* persian-date - 1.1.0
* Reza Babakhani <babakhani.reza@gmail.com>
* http://babakhani.github.io/PersianWebToolkit/docs/persian-date/
* Under MIT license
*
*
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.persianDate=t():e.persianDate=t()}(this,function(){return function(e){function t(i){if(a[i])return a[i].exports;var r=a[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var a={};return t.m=e,t.c=a,t.i=function(e){return e},t.d=function(e,a,i){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:i})},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=8)}([function(e,t,a){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,a,i){return a&&e(t.prototype,a),i&&e(t,i),t}}(),n=a(4).durationUnit,s=function(){function e(){i(this,e)}return r(e,[{key:"toPersianDigit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.toString().replace(/\d+/g,function(e){var a=[],i=[],r=void 0,n=void 0;for(r=0;r<e.length;r+=1)a.push(e.charCodeAt(r));for(n=0;n<a.length;n+=1)i.push(String.fromCharCode(a[n]+(t&&!0===t?1584:1728)));return i.join("")})}},{key:"leftZeroFill",value:function(e,t){for(var a=e+"";a.length<t;)a="0"+a;return a}},{key:"normalizeDuration",value:function(){var e=void 0,t=void 0;return"string"==typeof arguments[0]?(e=arguments[0],t=arguments[1]):(t=arguments[0],e=arguments[1]),n.year.indexOf(e)>-1?e="year":n.month.indexOf(e)>-1?e="month":n.week.indexOf(e)>-1?e="week":n.day.indexOf(e)>-1?e="day":n.hour.indexOf(e)>-1?e="hour":n.minute.indexOf(e)>-1?e="minute":n.second.indexOf(e)>-1?e="second":n.millisecond.indexOf(e)>-1&&(e="millisecond"),{unit:e,value:t}}},{key:"absRound",value:function(e){return e<0?Math.ceil(e):Math.floor(e)}},{key:"absFloor",value:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)}}]),e}();e.exports=s},function(e,t,a){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,a,i){return a&&e(t.prototype,a),i&&e(t,i),t}}(),n=a(10),s=a(2),o=a(0),h=a(5),u=a(11),d=(new o).toPersianDigit,l=(new o).leftZeroFill,c=(new o).normalizeDuration,y=a(7),f=a(6),v=function(){function t(e){return i(this,t),this.calendarType=t.calendarType,this.localType=t.localType,this.leapYearMode=t.leapYearMode,this.algorithms=new s(this),this.version="1.1.0",this._utcMode=!1,"fa"!==this.localType?this.formatPersian=!1:this.formatPersian="_default",this.State=this.algorithms.State,this.setup(e),this.State.isInvalidDate?new Date([-1,-1]):this}return r(t,[{key:"setup",value:function(e){if(n.isDate(e))this._gDateToCalculators(e);else if(n.isArray(e)){if(!u.validateInputArray(e))return this.State.isInvalidDate=!0,!1;this.algorithmsCalc([e[0],e[1]?e[1]:1,e[2]?e[2]:1,e[3]?e[3]:0,e[4]?e[4]:0,e[5]?e[5]:0,e[6]?e[6]:0])}else if(n.isNumber(e)){var a=new Date(e);this._gDateToCalculators(a)}else if(e instanceof t)this.algorithmsCalc([e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]);else if(e&&"/Date("===e.substring(0,6)){var i=new Date(parseInt(e.substr(6)));this._gDateToCalculators(i)}else{var r=new Date;this._gDateToCalculators(r)}}},{key:"_getSyncedClass",value:function(e){return new(t.toCalendar(this.calendarType).toLocale(this.localType).toLeapYearMode(this.leapYearMode))(e)}},{key:"_gDateToCalculators",value:function(e){this.algorithms.calcGregorian([e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()])}},{key:"rangeName",value:function(){var e=this.calendarType;return"fa"===this