refactor: handle unexpected data types

This commit is contained in:
cv
2023-09-27 12:16:39 +02:00
parent 52ca04e063
commit e09a7d99f0
+5 -1
View File
@@ -89,7 +89,11 @@ export const forgivingStringToMillis = (value: string, fillLeft = true): number
* @returns {number} - time in milliseconds
*/
export const parseExcelDate = (excelDate: string): number => {
export const parseExcelDate = (excelDate: unknown): number => {
if (typeof excelDate !== 'string') {
return 0;
}
// attempt converting to date object
const date = new Date(excelDate);
if (date instanceof Date && !isNaN(date.getTime())) {