diff : function (input, val, asFloat) {
var inputMoment = moment(input),
- diff = this._d - inputMoment._d,
+ zoneDiff = (this.zone() - inputMoment.zone()) * 6e4,
+ diff = this._d - inputMoment._d - zoneDiff,
year = this.year() - inputMoment.year(),
month = this.month() - inputMoment.month(),
date = this.date() - inputMoment.date(),
output;
+
if (val === 'months') {
output = year * 12 + month + date / 30;
} else if (val === 'years') {
equal(moment([2011, 0, 31]).diff([2011, 2, 1], 'months'), -1, "month diff");
});
-test("diff week", 1, function() {
- equal(moment([2012, 2, 18]).diff([2012], 'weeks'), 12, "week diff");
+test("diff across DST", 2, function() {
+ equal(moment([2012, 2, 24]).diff([2012, 2, 10], 'weeks', true), 2, "diff weeks across DST");
+ equal(moment([2012, 2, 24]).diff([2012, 2, 10], 'days', true), 14, "diff weeks across DST");
});
test("diff overflow", 4, function() {