mirror of
https://github.com/directus/directus.git
synced 2026-01-14 22:08:06 -05:00
Co-authored-by: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Co-authored-by: ian <licitdev@gmail.com> Co-authored-by: Rijk van Zanten <rijkvanzanten@me.com>
7 lines
323 B
TypeScript
7 lines
323 B
TypeScript
export function validateDateDifference(expectedDate: Date, receivedDate: Date, maxDifferenceMs: number): Date {
|
|
const difference = Math.abs(expectedDate.getTime() - receivedDate.getTime());
|
|
|
|
// Return the received date if within the acceptable range
|
|
return difference <= maxDifferenceMs ? receivedDate : expectedDate;
|
|
}
|