Skip to content

remove moment from global scope and add module dev dependencies for testing #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions moment-precise-range.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if (typeof moment === "undefined" && require) {
moment = require('moment');
var moment = require('moment');
}

(function(moment) {
Expand Down Expand Up @@ -55,9 +55,9 @@ if (typeof moment === "undefined" && require) {

moment.preciseDiff = function(d1, d2, returnValueObject) {
var m1 = moment(d1), m2 = moment(d2), firstDateWasLater;

m1.add(m2.utcOffset() - m1.utcOffset(), 'minutes'); // shift timezone of m1 to m2

if (m1.isSame(m2)) {
return STRINGS.nodiff;
}
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
"type": "git",
"url": "git+https://github.com/codebox/moment-precise-range.git"
},
"tonicExampleFilename" : "example/example.js",
"tonicExampleFilename": "example/example.js",
"author": "Rob Dawson <rob@codebox.org.uk> (http://codebox.org.uk)",
"license": "MIT",
"bugs": {
"url": "https://github.com/codebox/moment-precise-range/issues"
},
"homepage": "https://github.com/codebox/moment-precise-range#readme"
"homepage": "https://github.com/codebox/moment-precise-range#readme",
"devDependencies": {
"jasmine": "^2.5.0",
"moment": "^2.14.1"
}
}
5 changes: 3 additions & 2 deletions test/tests/moment-precise-range-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if (typeof require !== "undefined") {
var moment = require('moment');
require('../../moment-precise-range');
}

Expand Down Expand Up @@ -100,7 +101,7 @@ describe("preciseDiff", function() {
it("start month has fewer days than last full month", function() {
test('2013-04-29 00:00:00+0000', '2013-08-01 00:00:00+0000', '3 months 3 days');
test('2013-04-30 00:00:00+0000', '2013-08-01 00:00:00+0000', '3 months 2 days');
// no way to get '3 months 1 day' to 2013-08-01
// no way to get '3 months 1 day' to 2013-08-01
});
it("start month has same days as last full month", function() {
test('2013-05-30 00:00:00+0000', '2013-08-01 00:00:00+0000', '2 months 2 days');
Expand Down Expand Up @@ -170,4 +171,4 @@ describe("preciseDiff", function() {
});


});
});