Skip to content

Commit

Permalink
fix: fix diff bug when UTC plugin enabled (#1201)
Browse files Browse the repository at this point in the history
fix #1200
  • Loading branch information
iamkun authored Nov 10, 2020
1 parent ed9629b commit 9544ed2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugin/utc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions test/plugin/utc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down

0 comments on commit 9544ed2

Please sign in to comment.