Having trouble with date conversion in my custom pipe. It seems that when using a locale of 'nl-nl' and trying to format the date as 'dd-MM-YYYY', I'm seeing an error message stating
Unable to convert "16-02-2023" into a date for pipe 'DatePipe'
, while other dates like 02-09-2023
work fine.
import { DatePipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
import { ConfigurationService } from '../services/configuration.service';
@Pipe({
name: 'formattedDate',
})
export class FormattedDatePipe implements PipeTransform {
constructor(
private datePipe: DatePipe,
private configurationService: ConfigurationService,
) {}
transform(value: Date | string | number): string {
return this.datePipe.transform(value, this.configurationService.config.customer.dateFormat);
}
}
I suspect there may be confusion between day and month values causing the issue, but I haven't been able to pinpoint the exact cause.