feat: excel import (#527)

* refactor: simplify excel import

* chore: add external deepmerge utility

* chore: create import map utilities

* chore: increase size limits on uploads

* style: small presentation tweaks

* feat: resolve times on excel import, refs #508
This commit is contained in:
Carlos Valente
2023-11-11 14:28:43 +01:00
committed by GitHub
parent 0ce3449083
commit 45fe669f0a
61 changed files with 1905 additions and 685 deletions
+11 -7
View File
@@ -89,14 +89,18 @@ export const forgivingStringToMillis = (value: string, fillLeft = true): number
* @returns {number} - time in milliseconds
*/
export const parseExcelDate = (excelDate: string): number => {
// 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);
export const parseExcelDate = (excelDate: unknown): number => {
if (excelDate instanceof Date) {
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);
}
}
return 0;
};