@narmafzam/jalali-datepicker
Version:
just a jalali-datepicker
106 lines (104 loc) • 244 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["jalalidatepicker"] = factory();
else
root["jalalidatepicker"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/es6/index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./bower_components/persian-date/dist/persian-date.js":
/*!************************************************************!*\
!*** ./bower_components/persian-date/dist/persian-date.js ***!
\************************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("/*!\n * \n * persian-date - 1.0.5\n * Reza Babakhani <babakhani.reza@gmail.com>\n * http://babakhani.github.io/PersianWebToolkit/docs/persian-date/\n * Under WTFPL license \n * \n * \n */\n(function webpackUniversalModuleDefinition(root, factory) {\n\tif(true)\n\t\tmodule.exports = factory();\n\telse {}\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 8);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar durationUnit = __webpack_require__(4).durationUnit;\n\nvar Helpers = function () {\n function Helpers() {\n _classCallCheck(this, Helpers);\n }\n\n _createClass(Helpers, [{\n key: 'toPersianDigit',\n\n\n /**\n * @description return converted string to persian digit\n * @param digit\n * @returns {string|*}\n */\n value: function toPersianDigit(digit) {\n var latinDigit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n\n return digit.toString().replace(/\\d+/g, function (digit) {\n var enDigitArr = [],\n peDigitArr = [],\n i = void 0,\n j = void 0;\n for (i = 0; i < digit.length; i += 1) {\n enDigitArr.push(digit.charCodeAt(i));\n }\n for (j = 0; j < enDigitArr.length; j += 1) {\n peDigitArr.push(String.fromCharCode(enDigitArr[j] + (!!latinDigit && latinDigit === true ? 1584 : 1728)));\n }\n return peDigitArr.join('');\n });\n }\n\n /**\n * @param number\n * @param targetLength\n * @returns {string}\n */\n\n }, {\n key: 'leftZeroFill',\n value: function leftZeroFill(number, targetLength) {\n var output = number + '';\n while (output.length < targetLength) {\n output = '0' + output;\n }\n return output;\n }\n\n /**\n * @description normalize duration params and return valid param\n * @return {{unit: *, value: *}}\n */\n\n }, {\n key: 'normalizeDuration',\n value: function normalizeDuration() {\n var unit = void 0,\n value = void 0;\n if (typeof arguments[0] === 'string') {\n unit = arguments[0];\n value = arguments[1];\n } else {\n value = arguments[0];\n unit = arguments[1];\n }\n if (durationUnit.year.indexOf(unit) > -1) {\n unit = 'year';\n } else if (durationUnit.month.indexOf(unit) > -1) {\n unit = 'month';\n } else if (durationUnit.day.indexOf(unit) > -1) {\n unit = 'day';\n } else if (durationUnit.hour.indexOf(unit) > -1) {\n unit = 'hour';\n } else if (durationUnit.minute.indexOf(unit) > -1) {\n unit = 'minute';\n } else if (durationUnit.second.indexOf(unit) > -1) {\n unit = 'second';\n } else if (durationUnit.millisecond.indexOf(unit) > -1) {\n unit = 'millisecond';\n }\n return {\n unit: unit,\n value: value\n };\n }\n\n /**\n *\n * @param number\n * @returns {number}\n */\n\n }, {\n key: 'absRound',\n value: function absRound(number) {\n if (number < 0) {\n return Math.ceil(number);\n } else {\n return Math.floor(number);\n }\n }\n\n /**\n *\n * @param number\n * @return {number}\n */\n\n }, {\n key: 'absFloor',\n value: function absFloor(number) {\n if (number < 0) {\n // -0 -> 0\n return Math.ceil(number) || 0;\n } else {\n return Math.floor(number);\n }\n }\n }]);\n\n return Helpers;\n}();\n\nmodule.exports = Helpers;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar TypeChecking = __webpack_require__(10);\nvar Algorithms = __webpack_require__(2);\nvar Helpers = __webpack_require__(0);\nvar Duration = __webpack_require__(5);\nvar toPersianDigit = new Helpers().toPersianDigit;\nvar leftZeroFill = new Helpers().leftZeroFill;\nvar normalizeDuration = new Helpers().normalizeDuration;\nvar fa = __webpack_require__(7);\nvar en = __webpack_require__(6);\n\n/**\n * @description persian date class\n */\n\nvar PersianDateClass = function () {\n\n /**\n * @param input\n * @return {PersianDateClass}\n */\n function PersianDateClass(input) {\n _classCallCheck(this, PersianDateClass);\n\n this.calendarType = PersianDateClass.calendarType;\n this.localType = PersianDateClass.localType;\n this.leapYearMode = PersianDateClass.leapYearMode;\n\n this.algorithms = new Algorithms(this);\n this.version = \"1.0.5\";\n this._utcMode = false;\n if (this.localType !== 'fa') {\n this.formatPersian = false;\n } else {\n this.formatPersian = '_default';\n }\n this.setup(input);\n this.ON = this.algorithms.ON;\n return this;\n }\n\n /**\n * @param input\n */\n\n\n _createClass(PersianDateClass, [{\n key: 'setup',\n value: function setup(input) {\n // Convert Any thing to Gregorian Date\n if (TypeChecking.isDate(input)) {\n this._gDateToCalculators(input);\n } else if (TypeChecking.isArray(input)) {\n this.algorithmsCalc([input[0], input[1] ? input[1] : 1, input[2] ? input[2] : 1, input[3], input[4], input[5], input[6] ? input[6] : 0]);\n } else if (TypeChecking.isNumber(input)) {\n var fromUnix = new Date(input);\n this._gDateToCalculators(fromUnix);\n }\n // instance of pDate\n else if (input instanceof PersianDateClass) {\n this.algorithmsCalc([input.year(), input.month(), input.date(), input.hour(), input.minute(), input.second(), input.millisecond()]);\n }\n // ASP.NET JSON Date\n else if (input && input.substring(0, 6) === '/Date(') {\n var fromDotNet = new Date(parseInt(input.substr(6)));\n this._gDateToCalculators(fromDotNet);\n } else {\n var now = new Date();\n this._gDateToCalculators(now);\n }\n }\n\n /**\n * @param input\n * @return {*}\n * @private\n */\n\n }, {\n key: '_getSyncedClass',\n value: function _getSyncedClass(input) {\n var syncedCelander = PersianDateClass.toCalendar(this.calendarType).toLocale(this.localType).toLeapYearMode(this.leapYearMode);\n return new syncedCelander(input);\n }\n\n /**\n * @param inputgDate\n * @private\n */\n\n }, {\n key: '_gDateToCalculators',\n value: function _gDateToCalculators(inputgDate) {\n this.algorithms.calcGregorian([inputgDate.getFullYear(), inputgDate.getMonth(), inputgDate.getDate(), inputgDate.getHours(), inputgDate.getMinutes(), inputgDate.getSeconds(), inputgDate.getMilliseconds()]);\n }\n\n /**\n * @since 1.0.0\n * @description Helper method that return date range name like week days name, month names, month days names (specially in persian calendar).\n * @static\n * @return {*}\n */\n\n }, {\n key: 'rangeName',\n\n\n /**\n * @since 1.0.0\n * @description Helper method that return date range name like week days name, month names, month days names (specially in persian calendar).\n * @return {*}\n */\n value: function rangeName() {\n var t = this.calendarType;\n if (this.localType === 'fa') {\n if (t === 'persian') {\n return fa.persian;\n } else {\n return fa.gregorian;\n }\n } else {\n if (t === 'persian') {\n return en.persian;\n } else {\n return en.gregorian;\n }\n }\n }\n\n /**\n * @since 1.0.0\n * @param input\n * @return {PersianDateClass}\n */\n\n }, {\n key: 'toLeapYearMode',\n value: function toLeapYearMode(input) {\n this.leapYearMode = input;\n if (input === 'astronomical' && this.calendarType == 'persian') {\n this.leapYearMode = 'astronomical';\n } else if (input === 'algorithmic' && this.calendarType == 'persian') {\n this.leapYearMode = 'algorithmic';\n }\n this.algorithms.updateFromGregorian();\n return this;\n }\n\n /**\n * @since 1.0.0\n * @static\n * @param input\n * @return {PersianDateClass}\n */\n\n }, {\n key: 'toCalendar',\n\n\n /**\n * @since 1.0.0\n * @param input\n * @return {PersianDateClass}\n */\n value: function toCalendar(input) {\n this.calendarType = input;\n this.algorithms.updateFromGregorian();\n return this;\n }\n\n /**\n * @since 1.0.0\n * @static\n * @param input\n * @return {PersianDateClass}\n */\n\n }, {\n key: 'toLocale',\n\n\n /**\n * @since 1.0.0\n * @param input\n * @return {PersianDateClass}\n */\n value: function toLocale(input) {\n this.localType = input;\n if (this.localType !== 'fa') {\n this.formatPersian = false;\n } else {\n this.formatPersian = '_default';\n }\n return this;\n }\n\n /**\n * @return {*}\n * @private\n */\n\n }, {\n key: '_locale',\n value: function _locale() {\n var t = this.calendarType;\n if (this.localType === 'fa') {\n if (t === 'persian') {\n return fa.persian;\n } else {\n return fa.gregorian;\n }\n } else {\n if (t === 'persian') {\n return en.persian;\n } else {\n return en.gregorian;\n }\n }\n }\n\n /**\n * @param input\n * @private\n */\n\n }, {\n key: '_weekName',\n value: function _weekName(input) {\n return this._locale().weekdays[input - 1];\n }\n\n /**\n * @param input\n * @private\n */\n\n }, {\n key: '_weekNameShort',\n value: function _weekNameShort(input) {\n return this._locale().weekdaysShort[input - 1];\n }\n\n /**\n * @param input\n * @private\n */\n\n }, {\n key: '_weekNameMin',\n value: function _weekNameMin(input) {\n return this._locale().weekdaysMin[input - 1];\n }\n\n /**\n * @param input\n * @return {*}\n * @private\n */\n\n }, {\n key: '_dayName',\n value: function _dayName(input) {\n return this._locale().persianDaysName[input - 1];\n }\n\n /**\n * @param input\n * @private\n */\n\n }, {\n key: '_monthName',\n value: function _monthName(input) {\n return this._locale().months[input - 1];\n }\n\n /**\n * @param input\n * @private\n */\n\n }, {\n key: '_monthNameShort',\n value: function _monthNameShort(input) {\n return this._locale().monthsShort[input - 1];\n }\n\n /**\n * @param obj\n * @returns {boolean}\n */\n\n }, {\n key: 'isPersianDate',\n\n\n /**\n * @param obj\n * @return {boolean}\n */\n value: function isPersianDate(obj) {\n return obj instanceof PersianDateClass;\n }\n\n /**\n * @returns {PersianDate}\n */\n\n }, {\n key: 'clone',\n value: function clone() {\n return this._getSyncedClass(this.ON.gDate);\n }\n\n /**\n * @since 1.0.0\n * @param dateArray\n * @return {*}\n */\n\n }, {\n key: 'algorithmsCalc',\n value: function algorithmsCalc(dateArray) {\n if (this.isPersianDate(dateArray)) {\n dateArray = [dateArray.year(), dateArray.month(), dateArray.date(), dateArray.hour(), dateArray.minute(), dateArray.second(), dateArray.millisecond()];\n }\n if (this.calendarType === 'persian' && this.leapYearMode == 'algorithmic') {\n return this.algorithms.calcPersian(dateArray);\n } else if (this.calendarType === 'persian' && this.leapYearMode == 'astronomical') {\n return this.algorithms.calcPersiana(dateArray);\n } else if (this.calendarType === 'gregorian') {\n dateArray[1] = dateArray[1] - 1;\n return this.algorithms.calcGregorian(dateArray);\n }\n }\n\n /**\n * @since 1.0.0\n * @return {*}\n */\n\n }, {\n key: 'calendar',\n value: function calendar() {\n var key = void 0;\n if (this.calendarType == 'persian') {\n if (this.leapYearMode == 'astronomical') {\n key = 'persianAstro';\n } else if (this.leapYearMode == 'algorithmic') {\n key = 'persianAlgo';\n }\n } else {\n key = 'gregorian';\n }\n return this.ON[key];\n }\n\n /**\n * @description return Duration object\n * @param input\n * @param key\n * @returns {Duration}\n */\n\n }, {\n key: 'duration',\n\n\n /**\n * @description return Duration object\n * @param input\n * @param key\n * @returns {Duration}\n */\n value: function duration(input, key) {\n return new Duration(input, key);\n }\n\n /**\n * @description check if passed object is duration\n * @param obj\n * @returns {boolean}\n */\n\n }, {\n key: 'isDuration',\n\n\n /**\n * @description check if passed object is duration\n * @param obj\n * @returns {boolean}\n */\n value: function isDuration(obj) {\n return obj instanceof Duration;\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'years',\n value: function years(input) {\n return this.year(input);\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'year',\n value: function year(input) {\n if (input || input === 0) {\n this.algorithmsCalc([input, this.month(), this.date(), this.hour(), this.minute(), this.second(), this.millisecond()]);\n return this;\n } else {\n return this.calendar().year;\n }\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'month',\n value: function month(input) {\n if (input || input === 0) {\n this.algorithmsCalc([this.year(), input, this.date()]);\n return this;\n } else {\n return this.calendar().month + 1;\n }\n }\n\n /**\n * Day of week\n * @returns {Function|Date.toJSON.day|date_json.day|PersianDate.day|day|output.day|*}\n */\n\n }, {\n key: 'days',\n value: function days() {\n return this.day();\n }\n\n /**\n * @returns {Function|Date.toJSON.day|date_json.day|PersianDate.day|day|output.day|*}\n */\n\n }, {\n key: 'day',\n value: function day() {\n return this.calendar().weekday;\n }\n\n /**\n * Day of Months\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'dates',\n value: function dates(input) {\n return this.date(input);\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'date',\n value: function date(input) {\n if (input || input === 0) {\n this.algorithmsCalc([this.year(), this.month(), input]);\n return this;\n } else {\n return this.calendar().day;\n }\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'hour',\n value: function hour(input) {\n return this.hours(input);\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'hours',\n value: function hours(input) {\n if (input || input === 0) {\n this.algorithmsCalc([this.year(), this.month(), this.date(), input]);\n return this;\n } else {\n return this.ON.gDate.getHours();\n }\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'minute',\n value: function minute(input) {\n return this.minutes(input);\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'minutes',\n value: function minutes(input) {\n if (input || input === 0) {\n this.algorithmsCalc([this.year(), this.month(), this.date(), this.hour(), input]);\n return this;\n } else {\n return this.ON.gDate.getMinutes();\n }\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'second',\n value: function second(input) {\n return this.seconds(input);\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'seconds',\n value: function seconds(input) {\n if (input || input === 0) {\n this.algorithmsCalc([this.year(), this.month(), this.date(), this.hour(), this.minute(), input]);\n return this;\n } else {\n return this.ON.gDate.getSeconds();\n }\n }\n\n /**\n * @param input\n * @returns {*}\n * Getter Setter\n */\n\n }, {\n key: 'millisecond',\n value: function millisecond(input) {\n return this.milliseconds(input);\n }\n\n /**\n * @param input\n * @returns {*}\n */\n\n }, {\n key: 'milliseconds',\n value: function milliseconds(input) {\n if (input || input === 0) {\n this.algorithmsCalc([this.year(), this.month(), this.date(), this.hour(), this.minute(), this.second(), input]);\n return this;\n } else {\n return this.ON.gregorian.millisecond;\n }\n }\n\n /**\n * Return Milliseconds since the Unix Epoch (1318874398806)\n * @returns {*}\n * @private\n */\n // _valueOf () {\n // return this.ON.gDate.valueOf();\n // }\n\n\n }, {\n key: 'unix',\n\n\n /**\n * Return Unix Timestamp (1318874398)\n * @param timestamp\n * @returns {*}\n */\n value: function unix(timestamp) {\n var output = void 0;\n if (timestamp) {\n return this._getSyncedClass(timestamp * 1000);\n } else {\n var str = this.ON.gDate.valueOf().toString();\n output = str.substring(0, str.length - 3);\n }\n return parseInt(output);\n }\n\n /**\n * @returns {*}\n */\n\n }, {\n key: 'valueOf',\n value: function valueOf() {\n return this.ON.gDate.valueOf();\n }\n\n /**\n * @param year\n * @param month\n * @returns {*}\n * @since 1.0.0\n */\n\n }, {\n key: 'getFirstWeekDayOfMonth',\n\n\n /**\n * @param year\n * @param month\n * @returns {*}\n * @since 1.0.0\n */\n value: function getFirstWeekDayOfMonth(year, month) {\n return this._getSyncedClass([year, month, 1]).day();\n }\n\n /**\n * @param input\n * @param val\n * @param asFloat\n * @returns {*}\n */\n\n }, {\n key: 'diff',\n value: function diff(input, val, asFloat) {\n var self = this,\n inputMoment = input,\n zoneDiff = 0,\n diff = self.ON.gDate - inputMoment.toDate() - zoneDiff,\n year = self.year() - inputMoment.year(),\n month = self.month() - inputMoment.month(),\n date = (self.date() - inputMoment.date()) * -1,\n output = void 0;\n\n if (val === 'months' || val === 'month') {\n output = year * 12 + month + date / 30;\n } else if (val === 'years' || val === 'year') {\n output = year + (month + date / 30) / 12;\n } else {\n output = val === 'seconds' || val === 'second' ? diff / 1e3 : // 1000\n val === 'minutes' || val === 'minute' ? diff / 6e4 : // 1000 * 60\n val === 'hours' || val === 'hour' ? diff / 36e5 : // 1000 * 60 * 60\n val === 'days' || val === 'day' ? diff / 864e5 : // 1000 * 60 * 60 * 24\n val === 'weeks' || val === 'week' ? diff / 6048e5 : // 1000 * 60 * 60 * 24 * 7\n diff;\n }\n if (output < 0) {\n output = output * -1;\n }\n return asFloat ? output : Math.round(output);\n }\n\n /**\n * @param key\n * @returns {*}\n */\n\n }, {\n key: 'startOf',\n value: function startOf(key) {\n var syncedCelander = PersianDateClass.toCalendar(this.calendarType).toLocale(this.localType);\n // Simplify this\\\n /* jshint ignore:start */\n switch (key) {\n case 'years':\n case 'year':\n return new syncedCelander([this.year(), 1, 1]);\n case 'months':\n case 'month':\n return new syncedCelander([this.year(), this.month(), 1]);\n case 'days':\n case 'day':\n return new syncedCelander([this.year(), this.month(), this.date(), 0, 0, 0]);\n case 'hours':\n case 'hour':\n return new syncedCelander([this.year(), this.month(), this.date(), this.hours(), 0, 0]);\n case 'minutes':\n case 'minute':\n return new syncedCelander([this.year(), this.month(), this.date(), this.hours(), this.minutes(), 0]);\n case 'seconds':\n case 'second':\n return new syncedCelander([this.year(), this.month(), this.date(), this.hours(), this.minutes(), this.seconds()]);\n case 'weeks':\n case 'week':\n return new syncedCelander([this.year(), this.month(), this.date() - (this.calendar().weekday - 1)]);\n default:\n return this.clone();\n }\n /* jshint ignore:end */\n }\n\n /**\n * @param key\n * @returns {*}\n */\n /* eslint-disable no-case-declarations */\n\n }, {\n key: 'endOf',\n value: function endOf(key) {\n var syncedCelander = PersianDateClass.toCalendar(this.calendarType).toLocale(this.localType);\n // Simplify this\n switch (key) {\n case 'years':\n case 'year':\n var days = this.isLeapYear() ? 30 : 29;\n return new syncedCelander([this.year(), 12, days, 23, 59, 59]);\n case 'months':\n case 'month':\n var monthDays = this.daysInMonth(this.year(), this.month());\n return new syncedCelander([this.year(), this.month(), monthDays, 23, 59, 59]);\n case 'days':\n case 'day':\n return new syncedCelander([this.year(), this.month(), this.date(), 23, 59, 59]);\n case 'hours':\n case 'hour':\n return new syncedCelander([this.year(), this.month(), this.date(), this.hours(), 59, 59]);\n case 'minutes':\n case 'minute':\n return new syncedCelander([this.year(), this.month(), this.date(), this.hours(), this.minutes(), 59]);\n case 'seconds':\n case 'second':\n return new syncedCelander([this.year(), this.month(), this.date(), this.hours(), this.minutes(), this.seconds()]);\n case 'weeks':\n case 'week':\n var weekDayNumber = this.calendar().weekday;\n return new syncedCelander([this.year(), this.month(), this.date() + (7 - weekDayNumber)]);\n default:\n return this.clone();\n }\n /* eslint-enable no-case-declarations */\n }\n\n /**\n * @returns {*}\n */\n\n }, {\n key: 'sod',\n value: function sod() {\n return this.startOf('day');\n }\n\n /**\n * @returns {*}\n */\n\n }, {\n key: 'eod',\n value: function eod() {\n return this.endOf('day');\n }\n\n /** Get the timezone offset in minutes.\n * @return {*}\n */\n\n }, {\n key: 'zone',\n value: function zone(input) {\n if (input || input === 0) {\n this.ON.zone = input;\n return this;\n } else {\n return this.ON.zone;\n }\n }\n\n /**\n * @returns {PersianDate}\n */\n\n }, {\n key: 'local',\n value: function local() {\n var utcStamp = void 0;\n if (this._utcMode) {\n var ThatDayOffset = new Date(this.toDate()).getTimezoneOffset();\n var offsetMils = ThatDayOffset * 60 * 1000;\n if (ThatDayOffset < 0) {\n utcStamp = this.valueOf() - offsetMils;\n } else {\n /* istanbul ignore next */\n utcStamp = this.valueOf() + offsetMils;\n }\n this.toCalendar(PersianDateClass.calendarType);\n var utcDate = new Date(utcStamp);\n this._gDateToCalculators(utcDate);\n this._utcMode = false;\n this.zone(ThatDayOffset);\n return this;\n } else {\n return this;\n }\n }\n\n /**\n * @param input\n * @return {*}\n */\n\n }, {\n key: 'utc',\n\n\n /**\n * @description Current date/time in UTC mode\n * @param input\n * @returns {*}\n */\n value: function utc(input) {\n var utcStamp = void 0;\n if (input) {\n return this._getSyncedClass(input).utc();\n }\n if (this._utcMode) {\n return this;\n } else {\n var offsetMils = this.zone() * 60 * 1000;\n if (this.zone() < 0) {\n utcStamp = this.valueOf() + offsetMils;\n } else {\n /* istanbul ignore next */\n utcStamp = this.valueOf() - offsetMils;\n }\n var utcDate = new Date(utcStamp),\n d = this._getSyncedClass(utcDate);\n this.algorithmsCalc(d);\n this._utcMode = true;\n this.zone(0);\n return this;\n }\n }\n\n /**\n * @returns {boolean}\n */\n\n }, {\n key: 'isUtc',\n value: function isUtc() {\n return this._utcMode;\n }\n\n /**\n * @returns {boolean}\n * @link https://fa.wikipedia.org/wiki/%D8%B3%D8%A7%D8%B9%D8%AA_%D8%AA%D8%A7%D8%A8%D8%B3%D8%AA%D8%A7%D9%86%DB%8C\n */\n\n }, {\n key: 'isDST',\n value: function isDST() {\n var month = this.month(),\n day = this.date();\n if (month == 1 && day > 1 || month == 6 && day < 31 || month < 6 && month >= 2) {\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @returns {boolean}\n */\n\n }, {\n key: 'isLeapYear',\n value: function isLeapYear(year) {\n if (year === undefined) {\n year = this.year();\n }\n if (this.calendarType == 'persian' && this.leapYearMode === 'algorithmic') {\n return this.algorithms.leap_persian(year);\n }\n if (this.calendarType == 'persian' && this.leapYearMode === 'astronomical') {\n return this.algorithms.leap_persiana(year);\n } else if (this.calendarType == 'gregorian') {\n return this.algorithms.leap_gregorian(year);\n }\n }\n\n /**\n * @param yearInput\n * @param monthInput\n * @returns {number}\n */\n\n }, {\n key: 'daysInMonth',\n value: function daysInMonth(yearInput, monthInput) {\n var year = yearInput ? yearInput : this.year(),\n month = monthInput ? monthInput : this.month();\n if (this.calendarType === 'persian') {\n if (month < 1 || month > 12) return 0;\n if (month < 7) return 31;\n if (month < 12) return 30;\n if (this.isLeapYear(year)) {\n return 30;\n }\n return 29;\n }\n if (this.calendarType === 'gregorian') {\n return new Date(year, month, 0).getDate();\n }\n }\n\n /**\n * @description Return Native Javascript Date\n * @returns {*|PersianDate.gDate}\n */\n\n }, {\n key: 'toDate',\n value: function toDate() {\n return this.ON.gDate;\n }\n\n /**\n * @description Returns Array Of Persian Date\n * @returns {array}\n */\n\n }, {\n key: 'toArray',\n value: function toArray() {\n return [this.year(), this.month(), this.date(), this.hour(), this.minute(), this.second(), this.millisecond()];\n }\n\n /**\n * @returns {*}\n */\n\n }, {\n key: 'formatNumber',\n value: function formatNumber() {\n var output = void 0,\n self = this;\n\n // if default conf dosent set follow golbal config\n if (this.formatPersian === '_default') {\n if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {\n /* istanbul ignore next */\n if (self.formatPersian === false) {\n output = false;\n } else {\n // Default Conf\n output = true;\n }\n }\n /* istanbul ignore next */\n else {\n if (window.formatPersian === false) {\n output = false;\n } else {\n // Default Conf\n output = true;\n }\n }\n } else {\n if (this.formatPersian === true) {\n output = true;\n } else if (this.formatPersian === false) {\n output = false;\n } else {\n Error('Invalid Config \"formatPersian\" !!');\n }\n }\n return output;\n }\n\n /**\n * @param inputString\n * @returns {*}\n */\n\n }, {\n key: 'format',\n value: function format(inputString) {\n var self = this,\n formattingTokens = /([[^[]*])|(\\\\)?(Mo|MM?M?M?|Do|DD?D?D?|dddddd?|ddddd?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|SS?S?|zz?|ZZ?|X|LT|ll?l?l?|LL?L?L?)/g,\n info = {\n year: self.year(),\n month: self.month(),\n hour: self.hours(),\n minute: self.minutes(),\n second: self.seconds(),\n date: self.date(),\n timezone: self.zone(),\n unix: self.unix()\n },\n formatToPersian = self.formatNumber();\n\n var checkPersian = function checkPersian(i) {\n if (formatToPersian) {\n return toPersianDigit(i);\n } else {\n return i;\n }\n };\n\n /* jshint ignore:start */\n function replaceFunction(input) {\n switch (input) {\n // AM/PM\n case 'a':\n {\n if (formatToPersian) return info.hour >= 12 ? 'ب ظ' : 'ق ظ';else return info.hour >= 12 ? 'PM' : 'AM';\n }\n // Hours (Int)\n case 'H':\n {\n return checkPersian(info.hour);\n }\n case 'HH':\n {\n return checkPersian(leftZeroFill(info.hour, 2));\n }\n case 'h':\n {\n return checkPersian(info.hour % 12);\n }\n case 'hh':\n {\n return checkPersian(leftZeroFill(info.hour % 12, 2));\n }\n // Minutes\n case 'm':\n {\n return checkPersian(leftZeroFill(info.minute, 2));\n }\n // Two Digit Minutes\n case 'mm':\n {\n return checkPersian(leftZeroFill(info.minute, 2));\n }\n // Second\n case 's':\n {\n return checkPersian(info.second);\n }\n case 'ss':\n {\n return checkPersian(leftZeroFill(info.second, 2));\n }\n // Day (Int)\n case 'D':\n {\n return checkPersian(leftZeroFill(info.date));\n }\n // Return Two Digit\n case 'DD':\n {\n return checkPersian(leftZeroFill(info.date, 2));\n }\n // Return day Of Month\n case 'DDD':\n {\n var t = self.startOf('year');\n return checkPersian(leftZeroFill(self.diff(t, 'days'), 3));\n }\n // Return Day of Year\n case 'DDDD':\n {\n var _t = self.startOf('year');\n return checkPersian(leftZeroFill(self.diff(_t, 'days'), 3));\n }\n // Return day Of week\n case 'd':\n {\n return checkPersian(self.calendar().weekday);\n }\n // Return week day name abbr\n case 'ddd':\n {\n return self._weekNameShort(self.calendar().weekday);\n }\n case 'dddd':\n {\n return self._weekName(self.calendar().weekday);\n }\n // Return Persian Day Name\n case 'ddddd':\n {\n return self._dayName(self.calendar().day);\n }\n // Return Persian Day Name\n case 'dddddd':\n {\n return self._weekNameMin(self.calendar().weekday);\n }\n // Return Persian Day Name\n case 'w':\n {\n var _t2 = self.startOf('year'),\n day = parseInt(self.diff(_t2, 'days') / 7) + 1;\n return checkPersian(day);\n }\n // Return Persian Day Name\n case 'ww':\n {\n var _t3 = self.startOf('year'),\n _day = leftZeroFill(parseInt(self.diff(_t3, 'days') / 7) + 1, 2);\n return checkPersian(_day);\n }\n // Month (Int)\n case 'M':\n {\n return checkPersian(info.month);\n }\n // Two Digit Month (Str)\n case 'MM':\n {\n return checkPersian(leftZeroFill(info.month, 2));\n }\n // Abbr String of Month (Str)\n case 'MMM':\n {\n return self._monthNameShort(info.month);\n }\n // Full String name of Month (Str)\n case 'MMMM':\n {\n return self._monthName(info.month);\n }\n // Year\n // Two Digit Year (Str)\n case 'YY':\n {\n var yearDigitArray = info.year.toString().split('');\n return checkPersian(yearDigitArray[2] + yearDigitArray[3]);\n }\n // Full Year (Int)\n case 'YYYY':\n {\n return checkPersian(info.year);\n }\n /* istanbul ignore next */\n case 'Z':\n {\n var flag = '+',\n hours = Math.round(info.timezone / 60),\n minutes = info.timezone % 60;\n\n if (minutes < 0) {\n minutes *= -1;\n }\n if (hours < 0) {\n flag = '-';\n hours *= -1;\n }\n\n var z = flag + leftZeroFill(hours, 2) + ':' + leftZeroFill(minutes, 2);\n return checkPersian(z);\n }\n /* istanbul ignore next */\n case 'ZZ':\n {\n var _flag = '+',\n _hours = Math.round(info.timezone / 60),\n _minutes = info.timezone % 60;\n\n if (_minutes < 0) {\n