mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-30 11:29:11 +00:00
refactor: g-sheet time is object
This commit is contained in:
@@ -90,17 +90,17 @@ export const forgivingStringToMillis = (value: string, fillLeft = true): number
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
export const parseExcelDate = (excelDate: unknown): number => {
|
export const parseExcelDate = (excelDate: unknown): number => {
|
||||||
if (typeof excelDate !== 'string') {
|
if (excelDate instanceof Date) {
|
||||||
return 0;
|
return dateToMillis(excelDate);
|
||||||
|
} else if (typeof excelDate === 'string') {
|
||||||
|
const date = new Date(excelDate);
|
||||||
|
if (date instanceof Date && !isNaN(date.getTime())) {
|
||||||
|
return dateToMillis(date);
|
||||||
|
} else if (isTimeString(excelDate)) {
|
||||||
|
return forgivingStringToMillis(excelDate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attempt converting to date object
|
|
||||||
const date = new Date(excelDate);
|
|
||||||
if (date instanceof Date && !isNaN(date.getTime())) {
|
|
||||||
return dateToMillis(date);
|
|
||||||
} else if (isTimeString(excelDate)) {
|
|
||||||
return forgivingStringToMillis(excelDate);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user