days = this._days + this._milliseconds / 864e5;
months = this._months + daysToYears(days) * 12;
return units === 'month' ? months : months / 12;
- } else {
- // handle milliseconds separately because of floating point math errors (issue #1867)
+ } else {
+ // handle milliseconds separately because of floating point math errors (issue #1867)
days = this._days + yearsToDays(this._months / 12);
switch (units) {
case 'week': return days / 7 + this._milliseconds / 6048e5;
case 'hour': return days * 24 + this._milliseconds / 36e5;
case 'minute': return days * 24 * 60 + this._milliseconds / 6e4;
case 'second': return days * 24 * 60 * 60 + this._milliseconds / 1000;
- // Math.floor prevents floating point math errors here
+ // Math.floor prevents floating point math errors here
case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + this._milliseconds;
default: throw new Error('Unknown unit ' + units);
}
test.done();
},
- 'as getters for small units' : function (test) {
+ 'as getters for small units' : function (test) {
var dS = moment.duration(1, 'milliseconds'),
ds = moment.duration(3, 'seconds'),
dm = moment.duration(13, 'minutes');
test.equal(dm.asMinutes(), 13, 'asMinutes()');
test.done();
},
-
+
'isDuration' : function (test) {
test.expect(3);
test.ok(moment.isDuration(moment.duration(12345678)), 'correctly says true');