moment-jalaali
Advanced tools
Comparing version 0.7.4 to 0.8.0
@@ -82,2 +82,7 @@ | ||
function toJalaali(gy, gm, gd) { | ||
if (Object.prototype.toString.call(gy) === '[object Date]') { | ||
gd = gy.getDate() | ||
gm = gy.getMonth() + 1 | ||
gy = gy.getFullYear() | ||
} | ||
return d2j(g2d(gy, gm, gd)) | ||
@@ -939,3 +944,3 @@ } | ||
if (typeof input === 'string') { | ||
input = this.lang().jMonthsParse(input) | ||
input = this.localeData().jMonthsParse(input) | ||
if (typeof input !== 'number') | ||
@@ -942,0 +947,0 @@ return this |
@@ -627,3 +627,3 @@ | ||
if (typeof input === 'string') { | ||
input = this.lang().jMonthsParse(input) | ||
input = this.localeData().jMonthsParse(input) | ||
if (typeof input !== 'number') | ||
@@ -630,0 +630,0 @@ return this |
{ | ||
"name": "moment-jalaali", | ||
"version": "0.7.4", | ||
"version": "0.8.0", | ||
"description": "Jalaali (Jalali, Persian, Khorshidi, Shamsi) calendar system plugin for moment.js.", | ||
@@ -38,11 +38,12 @@ "author": { | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"eslint": "^4.19.1", | ||
"mocha": "^5.1.1" | ||
"chai": "^4.2.0", | ||
"eslint": "^5.6.1", | ||
"mocha": "^5.2.0" | ||
}, | ||
"dependencies": { | ||
"jalaali-js": "^1.1.0", | ||
"moment": "^2.22.1", | ||
"moment": "^2.22.2", | ||
"moment-timezone": "^0.5.21", | ||
"rimraf": "^2.6.2" | ||
} | ||
} |
646
test.js
@@ -26,4 +26,4 @@ | ||
it('should parse gregorian dates', function() { | ||
var m = moment('1981/8/17 07:10:20', 'YYYY/M/D hh:mm:ss') | ||
m.format('YYYY-MM-DD hh:mm:ss').should.be.equal('1981-08-17 07:10:20') | ||
var m = moment('1980/5/15 07:10:20', 'YYYY/M/D hh:mm:ss') | ||
m.format('YYYY-MM-DD hh:mm:ss').should.be.equal('1980-05-15 07:10:20') | ||
m.milliseconds().should.be.equal(0) | ||
@@ -38,28 +38,28 @@ }) | ||
it('should parse when only Jalaali year is in the format', function() { | ||
var m = moment('08 1360 17', 'MM jYYYY DD') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-17') | ||
m = moment('08 60 17', 'MM jYY DD') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-17') | ||
var m = moment('05 1359 15', 'MM jYYYY DD') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-15') | ||
m = moment('05 59 15', 'MM jYY DD') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-15') | ||
}) | ||
it('should parse when only Jalaali month is in the format', function() { | ||
var m = moment('1981 5 17', 'YYYY jM D') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-07-17') | ||
var m = moment('1980 2 15', 'YYYY jM D') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-04-15') | ||
}) | ||
it('should parse when only Jalaali month string is in the format', function() { | ||
var m = moment('1981 Amo 17', 'YYYY jMMM D') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-07-17') | ||
m = moment('1981 Amordaad 17', 'YYYY jMMMM D') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-07-17') | ||
var m = moment('1980 Ord 15', 'YYYY jMMM D') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-04-15') | ||
m = moment('1980 Ordibehesht 15', 'YYYY jMMMM D') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-04-15') | ||
}) | ||
it('should parse when only Jalaali date is in the format', function() { | ||
var m = moment('1981 26 8', 'YYYY jD M') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-15') | ||
var m = moment('1980 24 5', 'YYYY jD M') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-13') | ||
}) | ||
it('should parse when Jalaali year and month are in the format', function() { | ||
var m = moment('17 1360 5', 'D jYYYY jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-07-17') | ||
var m = moment('15 1359 2', 'D jYYYY jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-04-15') | ||
m = moment('1392 7', 'jYYYY jM') | ||
@@ -70,19 +70,19 @@ m.format('YYYY-MM-DD').should.be.equal('2013-09-23') | ||
it('should parse when Jalaali year and date are in the format', function() { | ||
var m = moment('26 1360 8', 'jD jYYYY M') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-15') | ||
var m = moment('24 1359 5', 'jD jYYYY M') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-13') | ||
}) | ||
it('should parse when Jalaali month and date are in the format', function() { | ||
var m = moment('26 1981 5', 'jD YYYY jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-17') | ||
var m = moment('24 1980 2', 'jD YYYY jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-14') | ||
}) | ||
it('should parse when Jalaali year, month and date are in the format', function() { | ||
var m = moment('26 1360 5', 'jD jYYYY jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-17') | ||
var m = moment('24 1359 2', 'jD jYYYY jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-14') | ||
}) | ||
it('should parse with complex format', function() { | ||
var m = moment('17 26 50 1981 50 8 12', 'D jD jYYYY YYYY M M jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1981-08-17') | ||
var m = moment('15 24 50 1980 50 5 12', 'D jD jYYYY YYYY M M jM') | ||
m.format('YYYY-MM-DD').should.be.equal('1980-05-15') | ||
}) | ||
@@ -97,4 +97,4 @@ | ||
it('should be able to parse in utc', function() { | ||
var m = moment.utc('1360/5/26 07:10:20', 'jYYYY/jM/jD hh:mm:ss') | ||
m.format('YYYY-MM-DD hh:mm:ss Z').should.be.equal('1981-08-17 07:10:20 +00:00') | ||
var m = moment.utc('1359/2/24 07:10:20', 'jYYYY/jM/jD hh:mm:ss') | ||
m.format('YYYY-MM-DD hh:mm:ss Z').should.be.equal('1980-05-14 07:10:20 +00:00') | ||
}) | ||
@@ -134,60 +134,60 @@ | ||
it('should work normally when there is no Jalaali token', function() { | ||
var m = moment('1981-08-17 07:10:20') | ||
m.format('YYYY-MM-DD hh:mm:ss').should.be.equal('1981-08-17 07:10:20') | ||
var m = moment('1980-05-15 07:10:20') | ||
m.format('YYYY-MM-DD hh:mm:ss').should.be.equal('1980-05-15 07:10:20') | ||
}) | ||
it('should format to Jalaali with Jalaali tokens', function() { | ||
var m = moment('1981-08-17 07:10:20') | ||
m.format('jYYYY-jMM-jDD hh:mm:ss').should.be.equal('1360-05-26 07:10:20') | ||
var m = moment('1980-05-15 07:10:20') | ||
m.format('jYYYY-jMM-jDD hh:mm:ss').should.be.equal('1359-02-25 07:10:20') | ||
}) | ||
it('should format with escaped and unescaped tokens', function() { | ||
var m = moment('1981-08-17') | ||
m.format('[My] birt\\h y[ea]r [is] jYYYY or YYYY').should.be.equal('My birth year is 1360 or 1981') | ||
var m = moment('1980-05-15') | ||
m.format('[My] birt\\h y[ea]r [is] jYYYY or YYYY').should.be.equal('My birth year is 1359 or 1980') | ||
}) | ||
it('should format with mixed tokens', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jYYYY/jMM/jDD = YYYY-MM-DD').should.be.equal('1360/05/26 = 1981-08-17') | ||
var m = moment('1980-05-15') | ||
m.format('jYYYY/jMM/jDD = YYYY-MM-DD').should.be.equal('1359/02/25 = 1980-05-15') | ||
}) | ||
it('should format with jMo', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jMo').should.be.equal('5th') | ||
var m = moment('1980-05-15') | ||
m.format('jMo').should.be.equal('2nd') | ||
}) | ||
it('should format with jM', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jM').should.be.equal('5') | ||
var m = moment('1980-05-15') | ||
m.format('jM').should.be.equal('2') | ||
}) | ||
it('should format with jMM', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jMM').should.be.equal('05') | ||
var m = moment('1980-05-15') | ||
m.format('jMM').should.be.equal('02') | ||
}) | ||
it('should format with jMMM', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jMMM').should.be.equal('Amo') | ||
var m = moment('1980-05-15') | ||
m.format('jMMM').should.be.equal('Ord') | ||
}) | ||
it('should format with jMMMM', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jMMMM').should.be.equal('Amordaad') | ||
var m = moment('1980-05-15') | ||
m.format('jMMMM').should.be.equal('Ordibehesht') | ||
}) | ||
it('should format with jDo', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jDo').should.be.equal('26th') | ||
var m = moment('1980-05-15') | ||
m.format('jDo').should.be.equal('25th') | ||
}) | ||
it('should format with jD', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jD').should.be.equal('26') | ||
var m = moment('1980-05-15') | ||
m.format('jD').should.be.equal('25') | ||
}) | ||
it('should format with jDD', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jDD').should.be.equal('26') | ||
m = moment('1981-08-23') | ||
var m = moment('1980-05-15') | ||
m.format('jDD').should.be.equal('25') | ||
m = moment('1980-05-22') | ||
m.format('jDD').should.be.equal('01') | ||
@@ -197,15 +197,15 @@ }) | ||
it('should format with jDDD', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jDDD').should.be.equal('150') | ||
var m = moment('1980-05-15') | ||
m.format('jDDD').should.be.equal('56') | ||
}) | ||
it('should format with jDDDo', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jDDDo').should.be.equal('150th') | ||
var m = moment('1980-05-15') | ||
m.format('jDDDo').should.be.equal('56th') | ||
}) | ||
it('should format with jDDDD', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jDDDD').should.be.equal('150') | ||
m = moment('1981-03-21') | ||
var m = moment('1980-05-15') | ||
m.format('jDDDD').should.be.equal('056') | ||
m = moment('1980-03-21') | ||
m.format('jDDDD').should.be.equal('001') | ||
@@ -215,74 +215,74 @@ }) | ||
it('should format with jwo', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jwo').should.be.equal('22nd') | ||
var m = moment('1980-05-15') | ||
m.format('jwo').should.be.equal('9th') | ||
}) | ||
it('should format with jw', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jw').should.be.equal('22') | ||
var m = moment('1980-05-15') | ||
m.format('jw').should.be.equal('9') | ||
}) | ||
it('should format with jww', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jww').should.be.equal('22') | ||
m = moment('1981-04-23') | ||
m.format('jww').should.be.equal('05') | ||
var m = moment('1980-05-15') | ||
m.format('jww').should.be.equal('09') | ||
m = moment('1980-04-23') | ||
m.format('jww').should.be.equal('06') | ||
}) | ||
it('should format with jYY', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jYY').should.be.equal('60') | ||
var m = moment('1980-05-15') | ||
m.format('jYY').should.be.equal('59') | ||
}) | ||
it('should format with jYYYY', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jYYYY').should.be.equal('1360') | ||
var m = moment('1980-05-15') | ||
m.format('jYYYY').should.be.equal('1359') | ||
}) | ||
it('should format with jYYYYY', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jYYYYY').should.be.equal('01360') | ||
var m = moment('1980-05-15') | ||
m.format('jYYYYY').should.be.equal('01359') | ||
}) | ||
it('should format with jgg', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jgg').should.be.equal('60') | ||
var m = moment('1980-05-15') | ||
m.format('jgg').should.be.equal('59') | ||
}) | ||
it('should format with jgggg', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jgggg').should.be.equal('1360') | ||
var m = moment('1980-05-15') | ||
m.format('jgggg').should.be.equal('1359') | ||
}) | ||
it('should format with jggggg', function() { | ||
var m = moment('1981-08-17') | ||
m.format('jggggg').should.be.equal('01360') | ||
var m = moment('1980-05-15') | ||
m.format('jggggg').should.be.equal('01359') | ||
}) | ||
it('should work with long date formats too', function() { | ||
var m = moment('1981-08-17') | ||
var m = moment('1980-05-15') | ||
m.format('LT').should.be.equal('12:00 AM') | ||
m.format('LTS').should.be.equal('12:00:00 AM') | ||
m.format('L').should.be.equal('1360/05/26') | ||
m.format('l').should.be.equal('1360/5/26') | ||
m.format('LL').should.be.equal('26 Amordaad 1360') | ||
m.format('ll').should.be.equal('26 Amo 1360') | ||
m.format('LLL').should.be.equal('26 Amordaad 1360 12:00 AM') | ||
m.format('lll').should.be.equal('26 Amo 1360 12:00 AM') | ||
m.format('LLLL').should.be.equal('Monday, 26 Amordaad 1360 12:00 AM') | ||
m.format('llll').should.be.equal('Mon, 26 Amo 1360 12:00 AM') | ||
m.format('L').should.be.equal('1359/02/25') | ||
m.format('l').should.be.equal('1359/2/25') | ||
m.format('LL').should.be.equal('25 Ordibehesht 1359') | ||
m.format('ll').should.be.equal('25 Ord 1359') | ||
m.format('LLL').should.be.equal('25 Ordibehesht 1359 12:00 AM') | ||
m.format('lll').should.be.equal('25 Ord 1359 12:00 AM') | ||
m.format('LLLL').should.be.equal('Thursday, 25 Ordibehesht 1359 12:00 AM') | ||
m.format('llll').should.be.equal('Thu, 25 Ord 1359 12:00 AM') | ||
}) | ||
it('should work with long date formats too if we have time', function() { | ||
var m = moment('1981-08-17 12:15:45') | ||
var m = moment('1980-05-15 12:15:45') | ||
m.format('LT').should.be.equal('12:15 PM') | ||
m.format('LTS').should.be.equal('12:15:45 PM') | ||
m.format('L').should.be.equal('1360/05/26') | ||
m.format('l').should.be.equal('1360/5/26') | ||
m.format('LL').should.be.equal('26 Amordaad 1360') | ||
m.format('ll').should.be.equal('26 Amo 1360') | ||
m.format('LLL').should.be.equal('26 Amordaad 1360 12:15 PM') | ||
m.format('lll').should.be.equal('26 Amo 1360 12:15 PM') | ||
m.format('LLLL').should.be.equal('Monday, 26 Amordaad 1360 12:15 PM') | ||
m.format('llll').should.be.equal('Mon, 26 Amo 1360 12:15 PM') | ||
m.format('L').should.be.equal('1359/02/25') | ||
m.format('l').should.be.equal('1359/2/25') | ||
m.format('LL').should.be.equal('25 Ordibehesht 1359') | ||
m.format('ll').should.be.equal('25 Ord 1359') | ||
m.format('LLL').should.be.equal('25 Ordibehesht 1359 12:15 PM') | ||
m.format('lll').should.be.equal('25 Ord 1359 12:15 PM') | ||
m.format('LLLL').should.be.equal('Thursday, 25 Ordibehesht 1359 12:15 PM') | ||
m.format('llll').should.be.equal('Thu, 25 Ord 1359 12:15 PM') | ||
}) | ||
@@ -293,10 +293,10 @@ }) | ||
it('should return Jalaali year', function() { | ||
var m = moment('1981-08-17') | ||
m.jYear().should.be.equal(1360) | ||
var m = moment('1980-05-15') | ||
m.jYear().should.be.equal(1359) | ||
}) | ||
it('should set Jalaali year', function() { | ||
var m = moment('1981-08-17') | ||
var m = moment('1980-05-15') | ||
m.jYear(1392) | ||
m.format('jYYYY/jM/jD').should.be.equal('1392/5/26') | ||
m.format('jYYYY/jM/jD').should.be.equal('1392/2/25') | ||
m = moment('2013-03-20') | ||
@@ -315,16 +315,16 @@ m.format('jYY/jM/jD').should.be.equal('91/12/30') | ||
it('should return Jalaali month', function() { | ||
var m = moment('1981-08-17') | ||
m.jMonth().should.be.equal(4) | ||
var m = moment('1980-05-15') | ||
m.jMonth().should.be.equal(1) | ||
}) | ||
it('should set Jalaali month', function() { | ||
var m = moment('1981-08-17') | ||
m.jMonth(7) | ||
m.format('jYYYY/jM/jD').should.be.equal('1360/8/26') | ||
m = moment('2012-08-21') | ||
m.format('jYY/jM/jD').should.be.equal('91/5/31') | ||
var m = moment('1980-05-15') | ||
m.jMonth(4) | ||
m.format('jYYYY/jM/jD').should.be.equal('1359/5/25') | ||
m = moment('2012-05-20') | ||
m.format('jYY/jM/jD').should.be.equal('91/2/31') | ||
m.jMonth(11) | ||
m.format('jYY/jM/jD').should.be.equal('91/12/30') | ||
m = moment('2013-08-22') | ||
m.format('jYY/jM/jD').should.be.equal('92/5/31') | ||
m = moment('2013-05-21') | ||
m.format('jYY/jM/jD').should.be.equal('92/2/31') | ||
m.jMonth(11) | ||
@@ -341,10 +341,10 @@ m.format('jYY/jM/jD').should.be.equal('92/12/29') | ||
it('should return Jalaali date', function() { | ||
var m = moment('1981-08-17') | ||
m.jDate().should.be.equal(26) | ||
var m = moment('1980-05-15') | ||
m.jDate().should.be.equal(25) | ||
}) | ||
it('should set Jalaali date', function() { | ||
var m = moment('1981-08-17') | ||
var m = moment('1980-05-15') | ||
m.jDate(30) | ||
m.format('jYYYY/jM/jD').should.be.equal('1360/5/30') | ||
m.format('jYYYY/jM/jD').should.be.equal('1359/2/30') | ||
m = moment('2013-03-01') | ||
@@ -371,4 +371,4 @@ m.format('jYY/jM/jD').should.be.equal('91/12/11') | ||
it('should return Jalaali date of year', function() { | ||
var m = moment('1981-08-17') | ||
m.jDayOfYear().should.be.equal(150) | ||
var m = moment('1980-05-15') | ||
m.jDayOfYear().should.be.equal(56) | ||
m = moment('1981-03-21') | ||
@@ -383,17 +383,17 @@ m.jDayOfYear().should.be.equal(1) | ||
it('should set Jalaali date of year', function() { | ||
var m = moment('1981-08-17') | ||
var m = moment('1980-05-15') | ||
m.jDayOfYear(30) | ||
m.format('jYYYY/jM/jD').should.be.equal('1360/1/30') | ||
m.format('jYYYY/jM/jD').should.be.equal('1359/1/30') | ||
m.jDayOfYear(364) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/28') | ||
m.format('jYY/jM/jD').should.be.equal('59/12/28') | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/29') | ||
m.format('jYY/jM/jD').should.be.equal('59/12/29') | ||
m.jDayOfYear(366) | ||
m.format('jYY/jM/jD').should.be.equal('61/1/1') | ||
m.format('jYY/jM/jD').should.be.equal('60/1/1') | ||
m.jDayOfYear(1) | ||
m.format('jYY/jM/jD').should.be.equal('61/1/1') | ||
m.format('jYY/jM/jD').should.be.equal('60/1/1') | ||
m.jDayOfYear(90) | ||
m.format('jYY/jM/jD').should.be.equal('61/3/28') | ||
m.jDayOfYear(365 + 366) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/30') | ||
m.format('jYY/jM/jD').should.be.equal('60/3/28') | ||
m.jDayOfYear(365 + 365) | ||
m.format('jYY/jM/jD').should.be.equal('61/12/29') | ||
}) | ||
@@ -404,15 +404,24 @@ }) | ||
it('should return Jalaali week of year', function() { | ||
var m = moment('1981-08-17') | ||
m.jWeek().should.be.equal(22) | ||
var m = moment('1980-05-15') | ||
m.jWeek().should.be.equal(9) | ||
m.jDayOfYear(1) | ||
m.format('jYY/jM/jD').should.be.equal('60/1/1') | ||
m.format('jYY/jM/jD').should.be.equal('59/1/1') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(8) | ||
m.format('jYY/jM/jD').should.be.equal('60/1/8') | ||
m.format('jYY/jM/jD').should.be.equal('59/1/8') | ||
m.jWeek().should.be.equal(2) | ||
m.jDayOfYear(14) | ||
m.format('jYY/jM/jD').should.be.equal('60/1/14') | ||
m.jWeek().should.be.equal(2) | ||
m.format('jYY/jM/jD').should.be.equal('59/1/14') | ||
m.jWeek().should.be.equal(3) | ||
m.jDayOfYear(364) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/28') | ||
m.format('jYY/jM/jD').should.be.equal('59/12/28') | ||
m.jWeek().should.be.equal(53) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('59/12/29') | ||
m.jWeek().should.be.equal(53) | ||
m.jDayOfYear(366) | ||
m.format('jYY/jM/jD').should.be.equal('60/1/1') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(363) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/27') | ||
m.jWeek().should.be.equal(52) | ||
@@ -425,8 +434,8 @@ m.jDayOfYear(365) | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(363) | ||
m.format('jYY/jM/jD').should.be.equal('61/12/27') | ||
m.jWeek().should.be.equal(52) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('61/12/29') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('61/12/29') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(366) | ||
@@ -441,59 +450,50 @@ m.format('jYY/jM/jD').should.be.equal('62/1/1') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(367) | ||
m.format('jYY/jM/jD').should.be.equal('63/1/1') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('63/12/29') | ||
m.format('jYY/jM/jD').should.be.equal('62/12/29') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(366) | ||
m.format('jYY/jM/jD').should.be.equal('64/1/1') | ||
m.format('jYY/jM/jD').should.be.equal('62/12/30') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('64/12/29') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(366) | ||
m.format('jYY/jM/jD').should.be.equal('65/1/1') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(358) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/22') | ||
m.format('jYY/jM/jD').should.be.equal('62/12/22') | ||
m.jWeek().should.be.equal(52) | ||
m.jDayOfYear(359) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/23') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/23') | ||
m.jWeek().should.be.equal(52) | ||
m.jDayOfYear(360) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/24') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/24') | ||
m.jWeek().should.be.equal(52) | ||
m.jDayOfYear(361) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/25') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/25') | ||
m.jWeek().should.be.equal(52) | ||
m.jDayOfYear(362) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/26') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/26') | ||
m.jWeek().should.be.equal(52) | ||
m.jDayOfYear(363) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/27') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/27') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(364) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/28') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/28') | ||
m.jWeek().should.be.equal(1) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('65/12/29') | ||
m.jWeek().should.be.equal(53) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/29') | ||
m.jWeek().should.be.equal(1) | ||
}) | ||
it('should set Jalaali week of year', function() { | ||
var m = moment('1981-08-17') | ||
var m = moment('1980-05-15') | ||
m.jWeek(1) | ||
m.format('jYY/jM/jD').should.be.equal('60/1/3') | ||
m.jWeek(22) | ||
m.format('jYY/jM/jD').should.be.equal('60/5/26') | ||
m.format('jYY/jM/jD').should.be.equal('58/12/30') | ||
m.jWeek(9) | ||
m.format('jYY/jM/jD').should.be.equal('59/2/25') | ||
m.jWeek(52) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/24') | ||
m.format('jYY/jM/jD').should.be.equal('59/12/21') | ||
m.jWeek(53) | ||
m.format('jYY/jM/jD').should.be.equal('61/1/2') | ||
m.format('jYY/jM/jD').should.be.equal('59/12/28') | ||
m.jWeek(1) | ||
m.format('jYY/jM/jD').should.be.equal('61/1/2') | ||
m.format('jYY/jM/jD').should.be.equal('58/12/30') | ||
m.jWeek(0) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/24') | ||
m.format('jYY/jM/jD').should.be.equal('58/12/23') | ||
m.jWeek(-1) | ||
m.format('jYY/jM/jD').should.be.equal('59/12/18') | ||
m.format('jYY/jM/jD').should.be.equal('57/12/17') | ||
}) | ||
@@ -504,9 +504,18 @@ }) | ||
it('should return Jalaali week year', function() { | ||
var m = moment('1981-08-17') | ||
m.jWeekYear().should.be.equal(1360) | ||
var m = moment('1980-05-15') | ||
m.jWeekYear().should.be.equal(1359) | ||
m.jDayOfYear(1) | ||
m.format('jYY/jM/jD').should.be.equal('59/1/1') | ||
m.jWeekYear().should.be.equal(1359) | ||
m.jDayOfYear(364) | ||
m.format('jYY/jM/jD').should.be.equal('59/12/28') | ||
m.jWeekYear().should.be.equal(1359) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('59/12/29') | ||
m.jWeekYear().should.be.equal(1359) | ||
m.jDayOfYear(366) | ||
m.format('jYY/jM/jD').should.be.equal('60/1/1') | ||
m.jWeekYear().should.be.equal(1360) | ||
m.jDayOfYear(364) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/28') | ||
m.jDayOfYear(363) | ||
m.format('jYY/jM/jD').should.be.equal('60/12/27') | ||
m.jWeekYear().should.be.equal(1360) | ||
@@ -519,5 +528,2 @@ m.jDayOfYear(365) | ||
m.jWeekYear().should.be.equal(1361) | ||
m.jDayOfYear(363) | ||
m.format('jYY/jM/jD').should.be.equal('61/12/27') | ||
m.jWeekYear().should.be.equal(1361) | ||
m.jDayOfYear(365) | ||
@@ -529,8 +535,2 @@ m.format('jYY/jM/jD').should.be.equal('61/12/29') | ||
m.jWeekYear().should.be.equal(1362) | ||
m.jDayOfYear(365) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/29') | ||
m.jWeekYear().should.be.equal(1363) | ||
m.jDayOfYear(366) | ||
m.format('jYY/jM/jD').should.be.equal('62/12/30') | ||
m.jWeekYear().should.be.equal(1363) | ||
m.jDayOfYear(367) | ||
@@ -566,7 +566,7 @@ m.format('jYY/jM/jD').should.be.equal('63/1/1') | ||
it('should set Jalaali week year', function() { | ||
var m = moment('1981-08-17') | ||
m.jWeekYear(1361) | ||
m.format('jYY/jM/jD').should.be.equal('61/5/26') | ||
var m = moment('1980-05-15') | ||
m.jWeekYear(1360) | ||
m.format('jYY/jM/jD').should.be.equal('60/2/25') | ||
m.jWeekYear(1364) | ||
m.format('jYY/jM/jD').should.be.equal('64/5/26') | ||
m.format('jYY/jM/jD').should.be.equal('64/2/25') | ||
m.jDayOfYear(365) | ||
@@ -583,21 +583,21 @@ m.format('jYY/jM/jD').should.be.equal('64/12/29') | ||
it('should work as expected without jYear and jMonth', function() { | ||
var m = moment('1981-08-17 07:10:20') | ||
m.startOf('year').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-01-01 00:00:00') | ||
m = moment('1981-08-17 07:10:20') | ||
m.startOf('month').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-08-01 00:00:00') | ||
m = moment('1981-08-17 07:10:20') | ||
m.startOf('day').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-08-17 00:00:00') | ||
m = moment('1981-08-17 07:10:20') | ||
m.startOf('week').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-08-15 00:00:00') | ||
var m = moment('1980-05-15 07:10:20') | ||
m.startOf('year').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-01-01 00:00:00') | ||
m = moment('1980-05-15 07:10:20') | ||
m.startOf('month').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-05-01 00:00:00') | ||
m = moment('1980-05-15 07:10:20') | ||
m.startOf('day').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-05-15 00:00:00') | ||
m = moment('1980-05-15 07:10:20') | ||
m.startOf('week').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-05-10 00:00:00') | ||
}) | ||
it('should return start of Jalaali year, month and date', function() { | ||
var m = moment('1981-08-17 07:10:20') | ||
m.startOf('jYear').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-01-01 00:00:00') | ||
m = moment('1981-08-17 07:10:20') | ||
m.startOf('jMonth').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-05-01 00:00:00') | ||
m = moment('1981-08-17 07:10:20') | ||
m.startOf('day').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-05-26 00:00:00') | ||
m = moment('1981-08-17 07:10:20') | ||
m.startOf('week').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-05-24 00:00:00') | ||
var m = moment('1980-05-15 07:10:20') | ||
m.startOf('jYear').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-01-01 01:00:00') | ||
m = moment('1980-05-15 07:10:20') | ||
m.startOf('jMonth').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-02-01 00:00:00') | ||
m = moment('1980-05-15 07:10:20') | ||
m.startOf('day').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-02-25 00:00:00') | ||
m = moment('1980-05-15 07:10:20') | ||
m.startOf('week').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-02-20 00:00:00') | ||
}) | ||
@@ -608,21 +608,21 @@ }) | ||
it('should work as expected without jYear and jMonth', function() { | ||
var m = moment('1981-08-17 07:10:20') | ||
m.endOf('year').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-12-31 23:59:59') | ||
m = moment('1981-08-17 07:10:20') | ||
m.endOf('month').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-08-31 23:59:59') | ||
m = moment('1981-08-17 07:10:20') | ||
m.endOf('day').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-08-17 23:59:59') | ||
m = moment('1981-08-17 07:10:20') | ||
m.endOf('week').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1981-08-21 23:59:59') | ||
var m = moment('1980-05-15 07:10:20') | ||
m.endOf('year').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-12-31 23:59:59') | ||
m = moment('1980-05-15 07:10:20') | ||
m.endOf('month').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-05-31 23:59:59') | ||
m = moment('1980-05-15 07:10:20') | ||
m.endOf('day').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-05-15 23:59:59') | ||
m = moment('1980-05-15 07:10:20') | ||
m.endOf('week').format('YYYY-MM-DD HH:mm:ss').should.be.equal('1980-05-16 23:59:59') | ||
}) | ||
it('should return end of Jalaali year, month and date', function() { | ||
var m = moment('1981-08-17 07:10:20') | ||
m.endOf('jYear').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-12-29 23:59:59') | ||
m = moment('1981-08-17 07:10:20') | ||
m.endOf('jMonth').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-05-31 23:59:59') | ||
m = moment('1981-08-17 07:10:20') | ||
m.endOf('day').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-05-26 23:59:59') | ||
m = moment('1981-08-17 07:10:20') | ||
m.endOf('week').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-05-30 23:59:59') | ||
var m = moment('1980-05-15 07:10:20') | ||
m.endOf('jYear').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1360-01-01 00:59:59') | ||
m = moment('1980-05-15 07:10:20') | ||
m.endOf('jMonth').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-02-31 23:59:59') | ||
m = moment('1980-05-15 07:10:20') | ||
m.endOf('day').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-02-25 23:59:59') | ||
m = moment('1980-05-15 07:10:20') | ||
m.endOf('week').format('jYYYY-jMM-jDD HH:mm:ss').should.be.equal('1359-02-26 23:59:59') | ||
}) | ||
@@ -635,14 +635,14 @@ }) | ||
, gf = 'YYYY-MM-DD' | ||
moment('1981-08-17', gf).isValid().should.be.true | ||
moment('1981-08-31', gf).isValid().should.be.true | ||
moment('1981-09-31', gf).isValid().should.be.false | ||
moment('1360 mordaad 26', 'jYYYY jMMMM jD').isValid().should.be.false | ||
moment('1360/05/26', jf).isValid().should.be.true | ||
moment('1360/05/31', jf).isValid().should.be.true | ||
moment('1360/07/30', jf).isValid().should.be.true | ||
moment('1360/07/31', jf).isValid().should.be.false | ||
moment('1360/12/29', jf).isValid().should.be.true | ||
moment('1360/12/30', jf).isValid().should.be.false | ||
moment('1360/12/31', jf).isValid().should.be.false | ||
moment('1360/13/01', jf).isValid().should.be.false | ||
moment('1980-05-15', gf).isValid().should.be.true | ||
moment('1980-05-29', gf).isValid().should.be.true | ||
moment('1980-06-31', gf).isValid().should.be.false | ||
moment('1359 xordibehesht 25', 'jYYYY jMMMM jD').isValid().should.be.false | ||
moment('1359/02/25', jf).isValid().should.be.true | ||
moment('1359/02/31', jf).isValid().should.be.true | ||
moment('1359/04/30', jf).isValid().should.be.true | ||
moment('1359/04/32', jf).isValid().should.be.false | ||
moment('1359/12/29', jf).isValid().should.be.true | ||
moment('1359/12/30', jf).isValid().should.be.false | ||
moment('1359/12/31', jf).isValid().should.be.false | ||
moment('1359/13/01', jf).isValid().should.be.false | ||
moment('1393/11/00', jf).isValid().should.be.false | ||
@@ -655,6 +655,6 @@ }) | ||
var gf = 'YYYY-MM-DD' | ||
moment('1981-08-17', gf).isValid().should.be.true | ||
moment('1981-08-31', gf).isValid().should.be.true | ||
moment('1981-08-311', gf).isValid().should.be.true | ||
moment('1981-08-311', gf, true).isValid().should.be.false | ||
moment('1980-05-15', gf).isValid().should.be.true | ||
moment('1980-05-31', gf).isValid().should.be.true | ||
moment('1980-05-311', gf).isValid().should.be.true | ||
moment('1980-05-311', gf, true).isValid().should.be.false | ||
}) | ||
@@ -664,5 +664,5 @@ | ||
var jf = 'jYYYY/jMM/jDD' | ||
moment('1360/05/26', jf).isValid().should.be.true | ||
moment('1360/05/31', jf).isValid().should.be.true | ||
moment('1360/05/311', jf, true).isValid().should.be.false | ||
moment('1359/02/25', jf).isValid().should.be.true | ||
moment('1359/02/31', jf).isValid().should.be.true | ||
moment('1359/02/311', jf, true).isValid().should.be.false | ||
}) | ||
@@ -673,8 +673,8 @@ }) | ||
it('should return a cloned instance', function() { | ||
var m = moment('1360/5/26', 'jYYYY/jM/jD') | ||
var m = moment('1359/2/25', 'jYYYY/jM/jD') | ||
, c = m.clone() | ||
m.add(1, 'jYear') | ||
m.add(4, 'day') | ||
m.format('jYY/jM/jD').should.be.equal('61/5/30') | ||
c.format('jYY/jM/jD').should.be.equal('60/5/26') | ||
m.add(5, 'day') | ||
m.format('jYY/jM/jD').should.be.equal('60/2/30') | ||
c.format('jYY/jM/jD').should.be.equal('59/2/25') | ||
}) | ||
@@ -686,17 +686,17 @@ }) | ||
var gf = 'YYYY-M-D' | ||
, m = moment('1981-8-17', 'YYYY-M-D') | ||
moment(m).add(1, 'day').format(gf).should.be.equal('1981-8-18') | ||
moment(m).add(10, 'days').format(gf).should.be.equal('1981-8-27') | ||
moment(m).add(30, 'days').format(gf).should.be.equal('1981-9-16') | ||
moment(m).add(60, 'days').format(gf).should.be.equal('1981-10-16') | ||
, m = moment('1980-5-15', 'YYYY-M-D') | ||
moment(m).add(1, 'day').format(gf).should.be.equal('1980-5-16') | ||
moment(m).add(10, 'days').format(gf).should.be.equal('1980-5-25') | ||
moment(m).add(30, 'days').format(gf).should.be.equal('1980-6-14') | ||
moment(m).add(60, 'days').format(gf).should.be.equal('1980-7-14') | ||
moment(m).add(1, 'month').format(gf).should.be.equal('1981-9-17') | ||
moment(m).add(2, 'months').format(gf).should.be.equal('1981-10-17') | ||
moment(m).add(10, 'months').format(gf).should.be.equal('1982-6-17') | ||
moment(m).add(20, 'months').format(gf).should.be.equal('1983-4-17') | ||
moment(m).add(1, 'month').format(gf).should.be.equal('1980-6-15') | ||
moment(m).add(2, 'months').format(gf).should.be.equal('1980-7-15') | ||
moment(m).add(10, 'months').format(gf).should.be.equal('1981-3-15') | ||
moment(m).add(20, 'months').format(gf).should.be.equal('1982-1-15') | ||
moment(m).add(1, 'year').format(gf).should.be.equal('1982-8-17') | ||
moment(m).add(2, 'years').format(gf).should.be.equal('1983-8-17') | ||
moment(m).add(10, 'years').format(gf).should.be.equal('1991-8-17') | ||
moment(m).add(20, 'years').format(gf).should.be.equal('2001-8-17') | ||
moment(m).add(1, 'year').format(gf).should.be.equal('1981-5-15') | ||
moment(m).add(2, 'years').format(gf).should.be.equal('1982-5-15') | ||
moment(m).add(10, 'years').format(gf).should.be.equal('1990-5-15') | ||
moment(m).add(20, 'years').format(gf).should.be.equal('2000-5-15') | ||
}) | ||
@@ -706,21 +706,21 @@ | ||
var jf = 'jYYYY/jM/jD' | ||
, m = moment('1360/5/26', 'jYYYY/jM/jD') | ||
moment(m).add(1, 'day').format(jf).should.be.equal('1360/5/27') | ||
moment(m).add(4, 'days').format(jf).should.be.equal('1360/5/30') | ||
moment(m).add(10, 'days').format(jf).should.be.equal('1360/6/5') | ||
moment(m).add(30, 'days').format(jf).should.be.equal('1360/6/25') | ||
moment(m).add(60, 'days').format(jf).should.be.equal('1360/7/24') | ||
moment(m).add(365, 'days').format(jf).should.be.equal('1361/5/26') | ||
, m = moment('1359/2/25', 'jYYYY/jM/jD') | ||
moment(m).add(1, 'day').format(jf).should.be.equal('1359/2/26') | ||
moment(m).add(4, 'days').format(jf).should.be.equal('1359/2/29') | ||
moment(m).add(10, 'days').format(jf).should.be.equal('1359/3/4') | ||
moment(m).add(30, 'days').format(jf).should.be.equal('1359/3/24') | ||
moment(m).add(60, 'days').format(jf).should.be.equal('1359/4/23') | ||
moment(m).add(365, 'days').format(jf).should.be.equal('1360/2/25') | ||
moment(m).add(1, 'jmonth').format(jf).should.be.equal('1360/6/26') | ||
moment(m).add(2, 'jmonths').format(jf).should.be.equal('1360/7/26') | ||
moment(m).add(10, 'jmonths').format(jf).should.be.equal('1361/3/26') | ||
moment(m).add(20, 'jmonths').format(jf).should.be.equal('1362/1/26') | ||
moment(m).add(1, 'jmonth').format(jf).should.be.equal('1359/3/25') | ||
moment(m).add(2, 'jmonths').format(jf).should.be.equal('1359/4/25') | ||
moment(m).add(10, 'jmonths').format(jf).should.be.equal('1359/12/25') | ||
moment(m).add(20, 'jmonths').format(jf).should.be.equal('1360/10/25') | ||
moment(m).add(1, 'jyear').format(jf).should.be.equal('1361/5/26') | ||
moment(m).add(2, 'jyears').format(jf).should.be.equal('1362/5/26') | ||
moment(m).add(3, 'jyears').format(jf).should.be.equal('1363/5/26') | ||
moment(m).add(4, 'jyears').format(jf).should.be.equal('1364/5/26') | ||
moment(m).add(10, 'jyears').format(jf).should.be.equal('1370/5/26') | ||
moment(m).add(20, 'jyears').format(jf).should.be.equal('1380/5/26') | ||
moment(m).add(1, 'jyear').format(jf).should.be.equal('1360/2/25') | ||
moment(m).add(2, 'jyears').format(jf).should.be.equal('1361/2/25') | ||
moment(m).add(3, 'jyears').format(jf).should.be.equal('1362/2/25') | ||
moment(m).add(4, 'jyears').format(jf).should.be.equal('1363/2/25') | ||
moment(m).add(10, 'jyears').format(jf).should.be.equal('1369/2/25') | ||
moment(m).add(20, 'jyears').format(jf).should.be.equal('1379/2/25') | ||
}) | ||
@@ -746,17 +746,17 @@ | ||
var gf = 'YYYY-M-D' | ||
, m = moment('1981-8-17', 'YYYY-M-D') | ||
moment(m).subtract(1, 'day').format(gf).should.be.equal('1981-8-16') | ||
moment(m).subtract(10, 'days').format(gf).should.be.equal('1981-8-7') | ||
moment(m).subtract(30, 'days').format(gf).should.be.equal('1981-7-18') | ||
moment(m).subtract(60, 'days').format(gf).should.be.equal('1981-6-18') | ||
, m = moment('1980-5-15', 'YYYY-M-D') | ||
moment(m).subtract(1, 'day').format(gf).should.be.equal('1980-5-14') | ||
moment(m).subtract(10, 'days').format(gf).should.be.equal('1980-5-5') | ||
moment(m).subtract(30, 'days').format(gf).should.be.equal('1980-4-15') | ||
moment(m).subtract(60, 'days').format(gf).should.be.equal('1980-3-16') | ||
moment(m).subtract(1, 'month').format(gf).should.be.equal('1981-7-17') | ||
moment(m).subtract(2, 'months').format(gf).should.be.equal('1981-6-17') | ||
moment(m).subtract(10, 'months').format(gf).should.be.equal('1980-10-17') | ||
moment(m).subtract(20, 'months').format(gf).should.be.equal('1979-12-17') | ||
moment(m).subtract(1, 'month').format(gf).should.be.equal('1980-4-15') | ||
moment(m).subtract(2, 'months').format(gf).should.be.equal('1980-3-15') | ||
moment(m).subtract(10, 'months').format(gf).should.be.equal('1979-7-15') | ||
moment(m).subtract(20, 'months').format(gf).should.be.equal('1978-9-15') | ||
moment(m).subtract(1, 'year').format(gf).should.be.equal('1980-8-17') | ||
moment(m).subtract(2, 'years').format(gf).should.be.equal('1979-8-17') | ||
moment(m).subtract(10, 'years').format(gf).should.be.equal('1971-8-17') | ||
moment(m).subtract(20, 'years').format(gf).should.be.equal('1961-8-17') | ||
moment(m).subtract(1, 'year').format(gf).should.be.equal('1979-5-15') | ||
moment(m).subtract(2, 'years').format(gf).should.be.equal('1978-5-15') | ||
moment(m).subtract(10, 'years').format(gf).should.be.equal('1970-5-15') | ||
moment(m).subtract(20, 'years').format(gf).should.be.equal('1960-5-15') | ||
}) | ||
@@ -766,21 +766,21 @@ | ||
var jf = 'jYYYY/jM/jD' | ||
, m = moment('1360/5/26', 'jYYYY/jM/jD') | ||
moment(m).subtract(1, 'day').format(jf).should.be.equal('1360/5/25') | ||
moment(m).subtract(4, 'days').format(jf).should.be.equal('1360/5/22') | ||
moment(m).subtract(10, 'days').format(jf).should.be.equal('1360/5/16') | ||
moment(m).subtract(30, 'days').format(jf).should.be.equal('1360/4/27') | ||
moment(m).subtract(60, 'days').format(jf).should.be.equal('1360/3/28') | ||
moment(m).subtract(365, 'days').format(jf).should.be.equal('1359/5/26') | ||
, m = moment('1359/2/25', 'jYYYY/jM/jD') | ||
moment(m).subtract(1, 'day').format(jf).should.be.equal('1359/2/24') | ||
moment(m).subtract(4, 'days').format(jf).should.be.equal('1359/2/21') | ||
moment(m).subtract(10, 'days').format(jf).should.be.equal('1359/2/15') | ||
moment(m).subtract(30, 'days').format(jf).should.be.equal('1359/1/26') | ||
moment(m).subtract(60, 'days').format(jf).should.be.equal('1358/12/26') | ||
moment(m).subtract(365, 'days').format(jf).should.be.equal('1358/2/26') | ||
moment(m).subtract(1, 'jmonth').format(jf).should.be.equal('1360/4/26') | ||
moment(m).subtract(2, 'jmonths').format(jf).should.be.equal('1360/3/26') | ||
moment(m).subtract(10, 'jmonths').format(jf).should.be.equal('1359/7/26') | ||
moment(m).subtract(20, 'jmonths').format(jf).should.be.equal('1358/9/26') | ||
moment(m).subtract(1, 'jmonth').format(jf).should.be.equal('1359/1/25') | ||
moment(m).subtract(2, 'jmonths').format(jf).should.be.equal('1358/12/25') | ||
moment(m).subtract(10, 'jmonths').format(jf).should.be.equal('1358/4/25') | ||
moment(m).subtract(20, 'jmonths').format(jf).should.be.equal('1357/6/25') | ||
moment(m).subtract(1, 'jyear').format(jf).should.be.equal('1359/5/26') | ||
moment(m).subtract(2, 'jyears').format(jf).should.be.equal('1358/5/26') | ||
moment(m).subtract(3, 'jyears').format(jf).should.be.equal('1357/5/26') | ||
moment(m).subtract(4, 'jyears').format(jf).should.be.equal('1356/5/26') | ||
moment(m).subtract(10, 'jyears').format(jf).should.be.equal('1350/5/26') | ||
moment(m).subtract(20, 'jyears').format(jf).should.be.equal('1340/5/26') | ||
moment(m).subtract(1, 'jyear').format(jf).should.be.equal('1358/2/25') | ||
moment(m).subtract(2, 'jyears').format(jf).should.be.equal('1357/2/25') | ||
moment(m).subtract(3, 'jyears').format(jf).should.be.equal('1356/2/25') | ||
moment(m).subtract(4, 'jyears').format(jf).should.be.equal('1355/2/25') | ||
moment(m).subtract(10, 'jyears').format(jf).should.be.equal('1349/2/25') | ||
moment(m).subtract(20, 'jyears').format(jf).should.be.equal('1339/2/25') | ||
}) | ||
@@ -854,8 +854,8 @@ | ||
moment.loadPersian() | ||
m = moment('1981-08-17') | ||
m.format('D MMMM YYYY').should.be.equal('17 اوت 1981') | ||
m.format('jD jMMMM jYYYY').should.be.equal('26 امرداد 1360') | ||
m.calendar().should.be.equal('1360/05/26') | ||
m.format('LLLL').should.be.equal('دوشنبه، 26 امرداد 1360 00:00') | ||
m.format('llll').should.be.equal('دوشنبه، 26 امر 1360 00:00') | ||
m = moment('1980-05-15') | ||
m.format('D MMMM YYYY').should.be.equal('15 مه 1980') | ||
m.format('jD jMMMM jYYYY').should.be.equal('25 اردیبهشت 1359') | ||
m.calendar().should.be.equal('1359/02/25') | ||
m.format('LLLL').should.be.equal('پنجشنبه، 25 اردیبهشت 1359 00:00') | ||
m.format('llll').should.be.equal('پنجشنبه، 25 ارد 1359 00:00') | ||
moment.locale(ol) | ||
@@ -870,8 +870,8 @@ }) | ||
moment.loadPersian({usePersianDigits: true}) | ||
m = moment('1981-08-17') | ||
m.format('D MMMM YYYY').should.be.equal('۱۷ اوت ۱۹۸۱') | ||
m.format('jD jMMMM jYYYY').should.be.equal('۲۶ امرداد ۱۳۶۰') | ||
m.calendar().should.be.equal('۱۳۶۰/۰۵/۲۶') | ||
m.format('LLLL').should.be.equal('دوشنبه، ۲۶ امرداد ۱۳۶۰ ۰۰:۰۰') | ||
m.format('llll').should.be.equal('دوشنبه، ۲۶ امر ۱۳۶۰ ۰۰:۰۰') | ||
m = moment('1980-05-15') | ||
m.format('D MMMM YYYY').should.be.equal('۱۵ مه ۱۹۸۰') | ||
m.format('jD jMMMM jYYYY').should.be.equal('۲۵ اردیبهشت ۱۳۵۹') | ||
m.calendar().should.be.equal('۱۳۵۹/۰۲/۲۵') | ||
m.format('LLLL').should.be.equal('پنجشنبه، ۲۵ اردیبهشت ۱۳۵۹ ۰۰:۰۰') | ||
m.format('llll').should.be.equal('پنجشنبه، ۲۵ ارد ۱۳۵۹ ۰۰:۰۰') | ||
moment.locale(ol) | ||
@@ -886,9 +886,9 @@ }) | ||
moment.loadPersian({dialect: 'persian-modern'}) | ||
m = moment('1981-08-21') | ||
m.format('D MMMM YYYY').should.be.equal('21 اوت 1981') | ||
m.format('jD jMMMM jYYYY').should.be.equal('30 مرداد 1360') | ||
m.calendar().should.be.equal('1360/05/30') | ||
m.format('LLLL').should.be.equal('جمعه، 30 مرداد 1360 00:00') | ||
m.format('llll').should.be.equal('جمعه، 30 مرد 1360 00:00') | ||
m.format('dd lll').should.be.equal('ج 30 مرد 1360 00:00') | ||
m = moment('1980-05-19') | ||
m.format('D MMMM YYYY').should.be.equal('19 مه 1980') | ||
m.format('jD jMMMM jYYYY').should.be.equal('29 اردیبهشت 1359') | ||
m.calendar().should.be.equal('1359/02/29') | ||
m.format('LLLL').should.be.equal('دوشنبه، 29 اردیبهشت 1359 00:00') | ||
m.format('llll').should.be.equal('دوشنبه، 29 ارد 1359 00:00') | ||
m.format('dd lll').should.be.equal('د 29 ارد 1359 00:00') | ||
moment.locale(ol) | ||
@@ -900,4 +900,4 @@ }) | ||
it('should create a moment with unix epoch', function () { | ||
var unix = moment('1360/5/26', 'jYYYY/jM/jD').unix() | ||
moment.unix(unix).format('jYYYY/jM/jD').should.be.equal('1360/5/26') | ||
var unix = moment('1359/2/25', 'jYYYY/jM/jD').unix() | ||
moment.unix(unix).format('jYYYY/jM/jD').should.be.equal('1359/2/25') | ||
}) | ||
@@ -904,0 +904,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
101861
2831
4
+ Addedmoment-timezone@^0.5.21
+ Addedmoment-timezone@0.5.46(transitive)
Updatedmoment@^2.22.2