moment-business-time
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -232,2 +232,3 @@ var moment = require('moment'), | ||
// ensure `from` is always before `to` | ||
var from, to, diff = 0, multiplier = 1; | ||
@@ -243,2 +244,3 @@ if (this.isAfter(comparator)) { | ||
// normalise to nearest working times | ||
if (!from.isWorkingTime()) { | ||
@@ -251,2 +253,8 @@ from = from.nextWorkingTime(); | ||
// if `from` is now after `to` then we have two timestamps on the same night, so diff is zero | ||
if (from.isAfter(to)) { | ||
return 0; | ||
} | ||
// iterate to the same day | ||
while(from.format('L') !== to.format('L')) { | ||
@@ -266,3 +274,3 @@ if (unit === 'day') { | ||
console.warn('WARNING: passing `true` as a third argument to `workingDiff` may lead to ambiguous results'); | ||
console.warn('See https://github.com/lennym/moment-business-time/issues/12#issuecomment-199710566') | ||
console.warn('See https://github.com/lennym/moment-business-time/issues/12#issuecomment-199710566'); | ||
var hours = from.diff(to, 'hour', true), | ||
@@ -269,0 +277,0 @@ denominator = comparator.isWorkingDay() ? comparator : comparator.nextWorkingDay(), |
{ | ||
"name": "moment-business-time", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Query and manipulate moment objects within the context of business/working hours", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -444,2 +444,6 @@ var moment = require('../lib/business-hours'); | ||
it('returns zero for times on the same night over consecutive days', function () { | ||
moment('2016-10-16T18:00:00+00:00').workingDiff('2016-10-17T06:00:00+00:00', 'hours').should.equal(0); | ||
}); | ||
}); | ||
@@ -446,0 +450,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
36961
634