Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/plugin/objectSupport/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default (o, c, dayjs) => {
const proto = c.prototype
const isObject = obj => !(obj instanceof Date) && !(obj instanceof Array)
&& !proto.$utils().u(obj) && obj !== null && (obj.constructor.name === 'Object')
const isObject = obj => obj !== null && !(obj instanceof Date) && !(obj instanceof Array)
&& !proto.$utils().u(obj) && (obj.constructor.name === 'Object')
const prettyUnit = (u) => {
const unit = proto.$utils().p(u)
return unit === 'date' ? 'day' : unit
Expand Down
6 changes: 6 additions & 0 deletions test/plugin/objectSupport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ it('Constructor from Object UTC', () => {
expect(moment.utc(tests[i][0]).format(fmt)).toBe(result)
}
})

it('Constructor from null should return Invalid Date', () => {
expect(dayjs(null).isValid()).toBe(false)
expect(moment(null).isValid()).toBe(false)
})

it('Set from Object', () => {
for (let i = 0; i < tests.length; i += 1) {
expect(dayjs(now).set(tests[i][0]).format(fmt)).toBe(moment(now).set(tests[i][0]).format(fmt))
Expand Down