Skip to content

Commit

Permalink
Removed UTC based calculation for diff()
Browse files Browse the repository at this point in the history
All the diff unit tests now run in local time.
  • Loading branch information
botic committed Dec 20, 2013
1 parent d70b251 commit f652542
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions test/ringo/utils/dates_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,26 +324,17 @@ exports.testDiff = function() {
});

// 366 + 31 days = 397 days
a = new Date(Date.UTC(2012, 0, 1));
b = new Date(Date.UTC(2013, 1, 1));

assert.equal(dates.diff(a, b, "year"), 1);
assert.equal(dates.diff(a, b, "quarter"), 4);
assert.equal(dates.diff(a, b, "month"), 13);
assert.equal(dates.diff(a, b, "week"), 56);
assert.equal(dates.diff(a, b, "day"), 397);

// again Einstein, now with time diff
b = new Date(Date.UTC(2013, 1, 1, 20, 20, 20, 20));
a = new Date(2012, 0, 1);
b = new Date(2013, 1, 1);
assert.equal(dates.diff(a, b, "year"), 1);
assert.equal(dates.diff(a, b, "quarter"), 4);
assert.equal(dates.diff(a, b, "month"), 13);
assert.equal(dates.diff(a, b, "week"), 56);
assert.equal(dates.diff(a, b, "day"), 397);

// no difference in quarters
a = new Date(2013, 11, 1); // Q4/2013
b = new Date(2013, 9, 1); // Q4/2013
a = new Date(2013, 11, 1, 12, 0, 0); // Q4/2013
b = new Date(2013, 9, 1, 12, 0, 0); // Q4/2013
assert.equal(dates.diff(a, b, "year"), 0);
assert.equal(dates.diff(b, a, "year"), 0);
assert.equal(dates.diff(a, b, "quarter"), 0);
Expand Down

0 comments on commit f652542

Please sign in to comment.