projects/maplander/components/src/lib/pipes/format-date/format-date.pipe.ts
Name | libFormatDate |
transform | ||||||||||||
transform(value: any, mDate?: boolean, format?: "dd/MM/yyyy" | "dd MMMMM yyyy" | "dd MMMMM" | "EEEEE HH:mm" | "dd MMMMM HH:mm" | "dd MMMMM yyyy HH:mm")
|
||||||||||||
Parameters :
Returns :
any
|
import {Pipe, PipeTransform} from '@angular/core';
import {MDate} from '../../utils/classes';
@Pipe({
name: 'libFormatDate'
})
export class FormatDatePipe implements PipeTransform {
transform(value: any, mDate?: boolean, format?: 'dd/MM/yyyy' | 'dd MMMMM yyyy' | 'dd MMMMM' | 'EEEEE HH:mm' | 'dd MMMMM HH:mm' | 'dd MMMMM yyyy HH:mm'): any {
if (mDate) {
return new MDate(value).getFormat(format, {toLowerCase: true});
} else {
const d = new Date(Number(value));
return `${d.getDate() < 10 ? '0' + d.getDate() : d.getDate()}/${d.getMonth() < 10 ? '0' + d.getMonth() : d.getMonth()}/${d.getFullYear()}`;
}
}
}