jalali-moment
Advanced tools
Comparing version 3.3.4 to 3.3.5
@@ -587,2 +587,5 @@ | ||
} | ||
if (moment.ISO_8601 === format) { | ||
format = 'YYYY-MM-DDTHH:mm:ss.SSSZ'; | ||
} | ||
const inputIsJalali = isInputJalali(format, this, input); | ||
@@ -802,2 +805,15 @@ // var itsJalaliDate = (isJalali(this)); | ||
}; | ||
jMoment.fn.diff = function (input, unitOfTime) { | ||
if (isJalali(this)) { | ||
if (unitOfTime === 'd' || unitOfTime === 'day') { | ||
return moment.fn.diff.call(this, input, unitOfTime); | ||
} else if (unitOfTime === 'm' || unitOfTime === 'month') { | ||
return Math.abs(this.jMonth() - input.jMonth()); | ||
} else if (unitOfTime === 'y' || unitOfTime === 'year') { | ||
return Math.abs(this.jYear() - input.jYear()); | ||
} | ||
} else { | ||
return moment.fn.diff.call(this, input, unitOfTime); | ||
} | ||
}; | ||
@@ -804,0 +820,0 @@ jMoment.fn.dayOfYear = function (input) { |
{ | ||
"name": "jalali-moment", | ||
"version": "3.3.4", | ||
"version": "3.3.5", | ||
"description": "Manipulate and convert Jalali and Gregorian date easily", | ||
@@ -5,0 +5,0 @@ "author": { |
15
test.js
@@ -1170,10 +1170,19 @@ | ||
}); | ||
describe("test diff", function () { | ||
describe("jmoment vs moment", function () { | ||
it("ISO_8601", function () { | ||
//https://github.com/fingerpich/jalali-moment/issues/70 | ||
const d1 = moment('2019-10-26', moment.ISO_8601).format(); | ||
const d2 = jalaliMoment('2019-10-26', moment.ISO_8601).format(); | ||
d1.should.be.equal(d2); | ||
}); | ||
it("diff locale fa", function () { | ||
//https://github.com/fingerpich/jalali-moment/issues/78 | ||
const d1 = moment('2019-10-26').locale('fa').diff(moment('2019-10-28').locale('fa'), 'month') | ||
const d2 = moment('2019-10-26').locale('en').diff(moment('2019-10-28').locale('en'), 'month') | ||
const d1 = jalaliMoment('2019-10-26').locale('fa').diff(jalaliMoment('2019-10-28').locale('fa'), 'month'); | ||
const d2 = jalaliMoment('2019-10-26').locale('en').diff(jalaliMoment('2019-10-28').locale('en'), 'month'); | ||
const d3 = moment('2019-10-26').diff(moment('2019-10-28'), 'month'); | ||
d1.should.be.equal(d2); | ||
d2.should.be.equal(d3); | ||
}); | ||
}); | ||
}); | ||
`` |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1306422
4131