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];
};


}
