File

projects/maplander/components/src/lib/pipes/format-date/format-date.pipe.ts

Metadata

Name libFormatDate

Methods

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 :
Name Type Optional
value any No
mDate boolean Yes
format "dd/MM/yyyy" | "dd MMMMM yyyy" | "dd MMMMM" | "EEEEE HH:mm" | "dd MMMMM HH:mm" | "dd MMMMM yyyy HH:mm" Yes
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()}`;
    }
  }

}

result-matching ""

    No results matching ""