LP1822414 Angular format service formatValue pipe
authorBill Erickson <berickxx@gmail.com>
Sun, 26 May 2019 18:01:40 +0000 (11:01 -0700)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 31 Jul 2019 14:37:05 +0000 (10:37 -0400)
Create a pipe version of FormatService.transform() function so strings
may be generated from fields directly in templates.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/core/format.service.ts

index d2b2ce5..b0e8072 100644 (file)
@@ -108,6 +108,10 @@ export class FormatService {
 
             case 'timestamp':
                 const date = new Date(value);
+                if (Number.isNaN(date.getTime())) {
+                    console.error('Invalid date in format service', value);
+                    return '';
+                }
                 let fmt = this.dateFormat || 'shortDate';
                 if (params.datePlusTime) {
                     fmt = this.dateTimeFormat || 'short';