Fix for displaying dates with right month
This commit is contained in:
@@ -7,18 +7,24 @@ import * as moment from 'moment';
|
|||||||
})
|
})
|
||||||
export class DateFormatPipe implements PipeTransform {
|
export class DateFormatPipe implements PipeTransform {
|
||||||
|
|
||||||
defaultDateFormat: string;
|
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService) {
|
constructor(private settingsService: SettingsService) {
|
||||||
this.defaultDateFormat = this.settingsService.dateFormat;
|
|
||||||
this.defaultDateFormat = this.defaultDateFormat.replace('dd', 'DD');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(value: Date | moment.Moment, dateFormat: string): any {
|
transform(value: any, dateFormat: string): any {
|
||||||
if (dateFormat == null) {
|
const defaultDateFormat = this.settingsService.dateFormat.replace('dd', 'DD');
|
||||||
return moment(value).format(this.defaultDateFormat);
|
if (typeof value === 'undefined') {
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
return moment(value).format(dateFormat);
|
let dateVal;
|
||||||
|
if (value instanceof Array) {
|
||||||
|
dateVal = moment(value.join('-'), 'YYYY-MM-DD');
|
||||||
|
} else {
|
||||||
|
dateVal = moment(value);
|
||||||
|
}
|
||||||
|
if (dateFormat == null) {
|
||||||
|
return dateVal.format(defaultDateFormat);
|
||||||
|
}
|
||||||
|
return dateVal.format(dateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user