update datepipe implementation due to interface change

This commit is contained in:
jonaswinkler 2021-06-13 15:27:04 +02:00
parent 7323ec8d16
commit 1d4f25f930

View File

@ -11,12 +11,11 @@ const FORMAT_TO_ISO_FORMAT = {
@Pipe({ @Pipe({
name: 'customDate' name: 'customDate'
}) })
export class CustomDatePipe extends DatePipe implements PipeTransform { export class CustomDatePipe implements PipeTransform {
private defaultLocale: string private defaultLocale: string
constructor(@Inject(LOCALE_ID) locale: string, private settings: SettingsService) { constructor(@Inject(LOCALE_ID) locale: string, private datePipe: DatePipe, private settings: SettingsService) {
super(locale)
this.defaultLocale = locale this.defaultLocale = locale
} }
@ -24,9 +23,9 @@ export class CustomDatePipe extends DatePipe implements PipeTransform {
let l = locale || this.settings.get(SETTINGS_KEYS.DATE_LOCALE) || this.defaultLocale let l = locale || this.settings.get(SETTINGS_KEYS.DATE_LOCALE) || this.defaultLocale
let f = format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT) let f = format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT)
if (l == "iso-8601") { if (l == "iso-8601") {
return super.transform(value, FORMAT_TO_ISO_FORMAT[f], timezone) return this.datePipe.transform(value, FORMAT_TO_ISO_FORMAT[f], timezone)
} else { } else {
return super.transform(value, format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT), timezone, l) return this.datePipe.transform(value, format || this.settings.get(SETTINGS_KEYS.DATE_FORMAT), timezone, l)
} }
} }