moment-business-time
Advanced tools
Comparing version 0.6.2 to 0.7.0
@@ -101,5 +101,13 @@ var moment = require('moment'), | ||
function add(d, num, unit) { | ||
if(num < 0){ | ||
return subtract(d, -(num), unit); | ||
} | ||
unit = moment.normalizeUnits(unit); | ||
if (unit === 'day') { | ||
if (unit === 'day' ) { | ||
d = incrementDays('add')(num, d); | ||
@@ -113,2 +121,6 @@ } else if (unit) { | ||
function subtract(d, num, unit) { | ||
if(num < 0){ | ||
return add(d, -(num), unit); | ||
} | ||
unit = moment.normalizeUnits(unit); | ||
@@ -161,3 +173,3 @@ if (unit === 'day') { | ||
} else { | ||
return this.isAfter(openinghours[0]) && this.isBefore(openinghours[1]); | ||
return this.isSameOrAfter(openinghours[0]) && this.isSameOrBefore(openinghours[1]); | ||
} | ||
@@ -164,0 +176,0 @@ }; |
{ | ||
"name": "moment-business-time", | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"description": "Query and manipulate moment objects within the context of business/working hours", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,2 +44,19 @@ var moment = require('../lib/business-hours'); | ||
it('considers working time inclusive', function(){ | ||
moment.locale('en', { | ||
workinghours: { | ||
0: null, | ||
1: ['09:00:00', '17:00:00'], | ||
2: ['09:00:00', '17:00:00'], | ||
3: ['09:00:00', '17:00:00'], | ||
4: ['09:00:00', '17:00:00'], | ||
5: ['09:00:00', '17:00:00'], | ||
6: null | ||
} | ||
}); | ||
moment('2017-06-26 9:00:00').isWorkingTime().should.be.true; | ||
moment('2017-06-26 17:00:00').isWorkingTime().should.be.true; | ||
}); | ||
}); | ||
@@ -94,2 +111,10 @@ | ||
it('can add negative days', function(){ | ||
moment(now).addWorkingTime(-1, 'day').format(date).should.equal('2015-02-25'); | ||
}); | ||
}); | ||
@@ -220,2 +245,6 @@ | ||
it('can subtract negative days', function(){ | ||
moment(now).subtractWorkingTime(-2, 'day').format(date).should.equal('2015-03-02'); | ||
}); | ||
}); | ||
@@ -222,0 +251,0 @@ |
Sorry, the diff of this file is not supported yet
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
38136
661