Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jalaliday

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jalaliday - npm Package Compare versions

Comparing version 2.2.5 to 2.2.7

11

CHANGELOG.md

@@ -1,5 +0,14 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [2.2.7](https://github.com/alibaba-aero/jalaliday/compare/v2.2.6...v2.2.7) (2020-01-26)
### [2.2.6](https://github.com/alibaba-aero/jalaliday/compare/v2.2.5...v2.2.6) (2020-01-26)
### Bug Fixes
* **safari:** add one hour to startOf to prevent safari issue ([9c512ce](https://github.com/alibaba-aero/jalaliday/commit/9c512ce))
## [2.2.5](https://github.com/alibaba-aero/jalaliday/compare/v2.2.4...v2.2.5) (2019-10-31)

@@ -6,0 +15,0 @@

2

dist/jalaliday.cjs.min.js

@@ -1,1 +0,1 @@

"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.setFullYear(a),n.$d.setMonth(s-1),n.$d.setDate(o),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),h=this.$jD,u=this.set(D,1).add(o,Y).set(M,e-12*o);return u.set(D,Math.min(u.daysInMonth(),h))}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 d=new Date(this.$d);return d.setDate(d.getDate()+t),E(d,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.$g=function(t,r,n){return o(t)?this[r]:this.set(n,t)},i.year=function(t){return a(this)?this.$g(t,"$jy",Y):m.bind(this)(t)},i.month=function(t){return a(this)?this.$g(t,"$jM",M):b.bind(this)(t)},i.date=function(t){return a(this)?this.$g(t,"$jD",D):p.bind(this)(t)},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;
"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)).$set("hour",1)},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.setFullYear(a),n.$d.setMonth(s-1),n.$d.setDate(o),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),h=this.$jD,u=this.set(D,1).add(o,Y).set(M,e-12*o);return u.set(D,Math.min(u.daysInMonth(),h))}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 d=new Date(this.$d);return d.setDate(d.getDate()+t),E(d,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.$g=function(t,r,n){return o(t)?this[r]:this.set(n,t)},i.year=function(t){return a(this)?this.$g(t,"$jy",Y):m.bind(this)(t)},i.month=function(t){return a(this)?this.$g(t,"$jM",M):b.bind(this)(t)},i.date=function(t){return a(this)?this.$g(t,"$jD",D):p.bind(this)(t)},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;

@@ -313,3 +313,3 @@ function _slicedToArray(arr, i) {

var ins = wrapper(new Date(gy, gm - 1, gd), _this);
return isStartOf ? ins : ins.endOf(D);
return (isStartOf ? ins : ins.endOf(D)).$set('hour', 1); // prevent daylight saving issue in safari
};

@@ -316,0 +316,0 @@

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).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,y;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),y=s<a(j,3,1)?0:r(j)?1:2;var v=n((12*(M+y)+373)/367);return[j,v,s-a(j,v,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,y=a.padStart||a.s,v=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,I=e.add,w=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.setFullYear(s),r.$d.setMonth(h-1),r.$d.setDate(u),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 I.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),u=this.$jD,d=this.set(c,1).add(a,$).set(l,e-12*a);return d.set(c,Math.min(d.daysInMonth(),u))}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 o=new Date(this.$d);return o.setDate(o.getDate()+t),x(o,this)}return I.bind(this)(t,n)},e.format=function(t,n){var i=this;if(!s(this))return w.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 y(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 y(i.$jD,2,"0");default:return w.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=v(this,a);switch(e){case $:u/=12;break;case l:break;default:return O.bind(this)(t,n,i)}return i?u:_(u)},e.$g=function(t,n,i){return M(t)?this[n]:this.set(i,t)},e.year=function(t){return s(this)?this.$g(t,"$jy",$):Y.bind(this)(t)},e.month=function(t){return s(this)?this.$g(t,"$jM",l):C.bind(this)(t)},e.date=function(t){return s(this)?this.$g(t,"$jD",c):S.bind(this)(t)},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)}}});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t=t||self).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,y;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),y=s<a(j,3,1)?0:r(j)?1:2;var v=n((12*(M+y)+373)/367);return[j,v,s-a(j,v,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,y=a.padStart||a.s,v=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,I=e.add,w=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)).$set("hour",1)},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.setFullYear(s),r.$d.setMonth(h-1),r.$d.setDate(u),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 I.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),u=this.$jD,d=this.set(c,1).add(a,$).set(l,e-12*a);return d.set(c,Math.min(d.daysInMonth(),u))}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 o=new Date(this.$d);return o.setDate(o.getDate()+t),x(o,this)}return I.bind(this)(t,n)},e.format=function(t,n){var i=this;if(!s(this))return w.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 y(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 y(i.$jD,2,"0");default:return w.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=v(this,a);switch(e){case $:u/=12;break;case l:break;default:return O.bind(this)(t,n,i)}return i?u:_(u)},e.$g=function(t,n,i){return M(t)?this[n]:this.set(i,t)},e.year=function(t){return s(this)?this.$g(t,"$jy",$):Y.bind(this)(t)},e.month=function(t){return s(this)?this.$g(t,"$jM",l):C.bind(this)(t)},e.date=function(t){return s(this)?this.$g(t,"$jD",c):S.bind(this)(t)},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)}}});
{
"name": "jalaliday",
"version": "2.2.5",
"version": "2.2.7",
"description": "Persian (Jalali, Khorshidi) Plugin for Day.js",

@@ -64,3 +64,3 @@ "main": "dist/jalaliday.cjs.min.js",

"codecov": "^3.5.0",
"dayjs": "^1.8.15",
"dayjs": "^1.8.19",
"eslint": "^6.2.1",

@@ -67,0 +67,0 @@ "eslint-config-airbnb-base": "^14.0.0",

@@ -35,3 +35,3 @@ # Jalaliday

### Changing calendar
if you want to all new instanses of dayjs use `jalali` calendar, you can set default calendar
If you want to all new instanses of dayjs use `jalali` calendar, you can set default calendar
```javascript

@@ -48,2 +48,13 @@ dayjs.calendar('jalali') // Jalali Calendar

### Parse Date
- Parse Gregory date
```js
const date = dayjs('2018-04-04T16:00:00.000Z');
```
- Parse Jalali date
```js
const date = dayjs('1398-10-17', { jalali: true });
```
### Multiple Locale
with combination of `calendar` and `locale` we have multi language for real

@@ -50,0 +61,0 @@ ```javascript

@@ -17,3 +17,3 @@ export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})[-/]?(\d{0,2})(.*)?$/

jmonths: 'فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند'.split('_'),
ordinal: n => n,
ordinal: (n) => n,
relativeTime: {

@@ -20,0 +20,0 @@ future: 'در %s ثانیه‌ی آتی',

@@ -7,3 +7,3 @@ import jdate from './calendar'

const U = proto.$utils()
const $isJalali = v => v.$C === 'jalali'
const $isJalali = (v) => v.$C === 'jalali'
const $prettyUnit = U.prettyUnit || U.p

@@ -14,3 +14,3 @@ const $isUndefined = U.isUndefined || U.u

const $absFloor = U.absFloor || U.a
const wrapperOfTruth = action => function (...args) {
const wrapperOfTruth = (action) => function (...args) {
const unsure = action.bind(this)(...args)

@@ -117,3 +117,4 @@ unsure.$C = this.$C

const ins = wrapper(new Date(gy, gm - 1, gd), this)
return isStartOf ? ins : ins.endOf(C.D)
return (isStartOf ? ins : ins.endOf(C.D))
.$set('hour', 1) // prevent daylight saving issue in safari
}

@@ -120,0 +121,0 @@ const WModifier = (this.$W + (7 - dayjs.$fdow)) % 7

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc