diff --git a/src/plugin/utc/index.js b/src/plugin/utc/index.js index 5fb04979..b5b5f4e6 100644 --- a/src/plugin/utc/index.js +++ b/src/plugin/utc/index.js @@ -112,7 +112,7 @@ export default (option, Dayjs, dayjs) => { } const oldDiff = proto.diff proto.diff = function (input, units, float) { - if (this.$u === input.$u) { + if (input && this.$u === input.$u) { return oldDiff.call(this, input, units, float) } const localThis = this.local() diff --git a/test/plugin/utc.test.js b/test/plugin/utc.test.js index 7ef563cd..d9761f9c 100644 --- a/test/plugin/utc.test.js +++ b/test/plugin/utc.test.js @@ -237,6 +237,9 @@ describe('Diff', () => { expect(_.utc(d1).diff(_.utc(d2), 'm')).toBe(1440) }) }) + it('default diff', () => { + expect(dayjs().diff()).toBeDefined() + }) it('local.diff(utc)', () => { expect(dayjs(d1).diff(dayjs.utc(d2), 'days')) .toBe(moment(d1).diff(moment.utc(d2), 'days'))