Files
directus/tests/blackbox/utils/validate-date-difference.ts
Pascal Jufer 15b91dee34 Blackbox tests restructuring (#18122)
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>
2023-04-11 18:28:37 +02:00

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;
}