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

moment-business-time

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moment-business-time - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

14

lib/business-hours.js

@@ -252,12 +252,18 @@ var moment = require('moment'),

diff--;
from = from.addWorkingTime(1, 'day');
} else {
diff += from.diff(openingTimes(from)[1], unit, true);
from = openingTimes(from.nextWorkingDay())[0];
}
from = openingTimes(from.nextWorkingDay())[0];
}
if (unit === 'day') {
diff--;
} else {
if (unit !== 'day') {
diff += from.diff(to, unit, true);
} else if (detail) {
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')
var hours = from.diff(to, 'hour', true),
denominator = comparator.isWorkingDay() ? comparator : comparator.nextWorkingDay(),
total = openingTimes(denominator)[1].diff(openingTimes(denominator)[0], 'hour', true);
diff += hours/total;
}

@@ -264,0 +270,0 @@

{
"name": "moment-business-time",
"version": "0.4.1",
"version": "0.5.0",
"description": "Query and manipulate moment objects within the context of business/working hours",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -402,4 +402,13 @@ var moment = require('../lib/business-hours');

from.workingDiff(to, 'days').should.equal(-16);
to.workingDiff(from, 'days').should.equal(16);
from.workingDiff(to, 'days').should.equal(-15);
to.workingDiff(from, 'days').should.equal(15);
moment('2015-02-27T15:00:00').workingDiff(moment('2015-02-27T10:00:00'), 'day').should.equal(0);
moment('2015-02-27T15:00:00').workingDiff(moment('2015-02-27T10:00:00'), 'day', true).should.equal(0.625);
moment('2015-02-27T15:00:00').workingDiff(moment('2015-02-26T10:00:00'), 'day').should.equal(1)
moment('2015-02-27T15:00:00').workingDiff(moment('2015-02-26T10:00:00'), 'day', true).should.equal(1.625);
moment('2015-02-27T15:00:00').workingDiff(moment('2015-02-21T10:00:00'), 'day', true).should.equal(4.75);
moment('2015-02-21T10:00:00').workingDiff(moment('2015-02-27T15:00:00'), 'day', true).should.equal(-4.75);
});

@@ -406,0 +415,0 @@

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