From 554c05167c525e2ca73c6e47057f14d27a3abca8 Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 16 Oct 2020 16:57:42 +0200 Subject: [PATCH 1/2] Fix null reference error for invalid times Prevents null reference error in parsedTime.toISOTime().replace() if parsedTime is invalid --- src/app/material-timepicker/services/time-adapter.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/material-timepicker/services/time-adapter.ts b/src/app/material-timepicker/services/time-adapter.ts index 2c184046..b80b7bca 100755 --- a/src/app/material-timepicker/services/time-adapter.ts +++ b/src/app/material-timepicker/services/time-adapter.ts @@ -25,7 +25,9 @@ export class TimeAdapter { } const {format} = opts; const parsedTime = TimeAdapter.parseTime(time, opts).setLocale(TimeAdapter.DEFAULT_LOCALE); - + if (parsedTime.invalid) { + return null; + } if (format !== 24) { return parsedTime.toLocaleString({ ...DateTime.TIME_SIMPLE, From 53d0e91c7b021cc4cac2d25908f257531f39c8f0 Mon Sep 17 00:00:00 2001 From: Daniel Koch Date: Fri, 16 Oct 2020 17:37:41 +0200 Subject: [PATCH 2/2] Using isValid instead of invalid invalid is not a public field of the luxon.DateTime class, instead isValid should be used --- src/app/material-timepicker/services/time-adapter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/material-timepicker/services/time-adapter.ts b/src/app/material-timepicker/services/time-adapter.ts index b80b7bca..0f648b5f 100755 --- a/src/app/material-timepicker/services/time-adapter.ts +++ b/src/app/material-timepicker/services/time-adapter.ts @@ -25,7 +25,7 @@ export class TimeAdapter { } const {format} = opts; const parsedTime = TimeAdapter.parseTime(time, opts).setLocale(TimeAdapter.DEFAULT_LOCALE); - if (parsedTime.invalid) { + if (!parsedTime.isValid) { return null; } if (format !== 24) {