fix: strip milliseconds from date
This commit is contained in:
committed by
Khaled Garbaya
parent
9135162361
commit
777a8d4007
@@ -37,15 +37,21 @@ module.exports = async function attachEntryState (entry) {
|
||||
}
|
||||
})
|
||||
// If the field is a single reference we just check if it has pending changes
|
||||
} else if (isObject(item[0]) && (!item[0].fields || item[0].sys.updatedAt !== item[1].sys.updatedAt)) {
|
||||
} else if (isObject(item[0]) && (!item[0].fields || !isDateEqual(item[0].sys.updatedAt !== item[1].sys.updatedAt))) {
|
||||
entry.pendingChanges = true
|
||||
return
|
||||
}
|
||||
})
|
||||
// We check if the root element has pending changes
|
||||
if (entry && publishedEntry && (entry.sys.updatedAt !== publishedEntry.sys.updatedAt)) {
|
||||
if (entry && publishedEntry && (!isDateEqual(entry.sys.updatedAt !== publishedEntry.sys.updatedAt))) {
|
||||
entry.pendingChanges = true
|
||||
}
|
||||
|
||||
return entry
|
||||
}
|
||||
|
||||
function isDateEqual (lhs, rhs) {
|
||||
const lhsDate = new Date(lhs)
|
||||
const rhsDate = new Date(rhs)
|
||||
return lhsDate.setMilliseconds(0) === rhsDate.setMilliseconds(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user