diff --git a/src/plugin/duration/index.js b/src/plugin/duration/index.js index e2060c344..7c35c01d0 100644 --- a/src/plugin/duration/index.js +++ b/src/plugin/duration/index.js @@ -61,6 +61,11 @@ class Duration { constructor(input, unit, locale) { this.$d = {} this.$l = locale + + Object.defineProperty(this, 'valueOf', { + value: () => this.asMilliseconds() + }) + if (input === undefined) { this.$ms = 0 this.parseFromMilliseconds() @@ -236,10 +241,6 @@ class Duration { .fromNow(!withSuffix) } - valueOf() { - return this.asMilliseconds() - } - milliseconds() { return this.get('milliseconds') } asMilliseconds() { return this.as('milliseconds') } seconds() { return this.get('seconds') }