You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemmionic5/Mohem/src/app/pipes/date-string/date-string.ts

40 lines
1003 B
TypeScript

import { Pipe, PipeTransform } from '@angular/core';
/**
* Generated class for the DateStringPipe pipe.
*
* See https://angular.io/api/core/Pipe for more info on Angular Pipes.
*/
@Pipe({
name: 'dateString',
})
export class DateStringPipe implements PipeTransform {
/**
* Takes a value and makes it lowercase.
*/
locale = {
en: {
// month_names: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
month_names_short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}
};
transform(value: string) {
let x = new Date(Date.parse(value));
//return value.toLowerCase();
let month = this.getMonthNameShort('en',x.getMonth())
return ""+ x.getDate()+" "+ month +" "+x.getFullYear();
}
getMonthNameShort(lang,month) {
lang = lang && (lang in this.locale) ? lang : 'en';
return this.locale[lang].month_names_short[month];
};
}