import { daysToMonths, monthsToDays } from './bubble';
import { normalizeUnits } from '../units/aliases';
-import toInt from '../utils/to-int';
export function as(units) {
if (!this.isValid()) {
}
}
-// TODO: Use this.as('ms')?
-export function valueOf() {
- if (!this.isValid()) {
- return NaN;
- }
- return (
- this._milliseconds +
- this._days * 864e5 +
- (this._months % 12) * 2592e6 +
- toInt(this._months / 12) * 31536e6
- );
-}
-
function makeAs(alias) {
return function () {
return this.as(alias);
asWeeks = makeAs('w'),
asMonths = makeAs('M'),
asQuarters = makeAs('Q'),
- asYears = makeAs('y');
+ asYears = makeAs('y'),
+ valueOf = makeAs('ms');
export {
asMilliseconds,
asMonths,
asQuarters,
asYears,
+ valueOf,
};
};
durationObject.foo(5);
});
+
+test('valueOf and asMilliseconds have the same function', function (assert) {
+ var t1 = +moment.duration({ months: 2 }),
+ t2 = moment.duration({ months: 2 }).asMilliseconds();
+ assert.ok(t1 === t2, 'the final value should be equal');
+});