I have a custom pipe extended from DataPipe Angular class.
import { Pipe, PipeTransform } from '@angular/core';
import { DatePipe } from '@angular/common';
@Pipe({
name: 'dateTimeFormater'
})
export class DateTimeFormaterPipe extends DatePipe implements PipeTransform {
transform(value: any): string {
const currentDay = new Date().getDay();
const itemDate = new Date(value);
const elementDay = itemDate.getDay();
const format = currentDay === elementDay ? DatePipe['_ALIASES'].mediumTime : DatePipe['_ALIASES'].shortDate;
return super.transform(value, format );
}
}
I need to set locale (global) value from user language (not browser configuration). This value is getting from database when user login into application. I have this value in app.module for example.
Base class have a constructor with locale parameter but I don't know how to make a call with locale value. This value could be diferent depending on the context or user settings.
//common/pipes/ts/date_pipe.ts (angular code)
export declare class DatePipe implements PipeTransform {
private _locale;
constructor(_locale: string);
transform(value: any, pattern?: string): string | null;
}