mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 14:14:17 +00:00
refactor: handle unexpected data types
This commit is contained in:
@@ -89,7 +89,11 @@ export const forgivingStringToMillis = (value: string, fillLeft = true): number
|
|||||||
* @returns {number} - time in milliseconds
|
* @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
|
// attempt converting to date object
|
||||||
const date = new Date(excelDate);
|
const date = new Date(excelDate);
|
||||||
if (date instanceof Date && !isNaN(date.getTime())) {
|
if (date instanceof Date && !isNaN(date.getTime())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user