Files
immich/server/libs/common/src/utils/time-utils.ts
Alex 3e4a14b299 chore(server) harden EXIF extraction (#1347)
* chore(server) Harden EXIF extraction

* Remove unused function in timeutil

* Remove deadcode
2023-01-17 13:41:00 -06:00

22 lines
466 B
TypeScript

function createTimeUtils() {
const checkValidTimestamp = (timestamp: string): boolean => {
const parsedTimestamp = Date.parse(timestamp);
if (isNaN(parsedTimestamp)) {
return false;
}
const date = new Date(parsedTimestamp);
if (date.getFullYear() < 1583 || date.getFullYear() > 9999) {
return false;
}
return date.getFullYear() > 0;
};
return { checkValidTimestamp };
}
export const timeUtils = createTimeUtils();