diff --git a/ui-ngx/src/app/shared/adapter/custom-datatime-adapter.ts b/ui-ngx/src/app/shared/adapter/custom-datatime-adapter.ts index 51ba33d9da..50417a5914 100644 --- a/ui-ngx/src/app/shared/adapter/custom-datatime-adapter.ts +++ b/ui-ngx/src/app/shared/adapter/custom-datatime-adapter.ts @@ -17,21 +17,20 @@ import { Injectable } from '@angular/core'; import { NativeDatetimeAdapter } from '@mat-datetimepicker/core'; - @Injectable() export class CustomDateAdapter extends NativeDatetimeAdapter { - parse(value: string): Date { + parse(value: string | number): Date { if (typeof value === 'number') { return new Date(value); } - let newDate = null; + let newDate = value; const formatToParts = Intl.DateTimeFormat(this.locale).formatToParts(); if (formatToParts[0].type.toLowerCase() === 'day') { const literal = formatToParts[1].value; - newDate = value.replace(new RegExp(`(\\d+[${literal}])(\\d+[${literal}])`), '$2$1'); + newDate = newDate.replace(new RegExp(`(\\d+[${literal}])(\\d+[${literal}])`), '$2$1'); } - return value ? new Date(Date.parse(newDate || value)) : null; + return newDate ? new Date(Date.parse(newDate)) : null; } }