SUPPORT-9484: Delete zoneformatter
This commit is contained in:
parent
302a0798a3
commit
3e93d50d1e
1 changed files with 0 additions and 38 deletions
|
|
@ -1,38 +0,0 @@
|
||||||
import {DateTimeUtil, DefaultValueFormatter, GridValueFormatter} from "@webbpm/base-package";
|
|
||||||
import {ValueFormatterParams} from "ag-grid-community";
|
|
||||||
|
|
||||||
export class ZoneDateTimeFormatter extends DefaultValueFormatter implements GridValueFormatter {
|
|
||||||
|
|
||||||
public dateFormat: string = '';
|
|
||||||
private defaultFormat = 'DD.MM.YYYY HH:mm:ss (Z)';
|
|
||||||
|
|
||||||
format(params: ValueFormatterParams): string {
|
|
||||||
if (this.isValueEmpty(params)) {
|
|
||||||
return super.format(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
// don't apply formatter to row with aggregation function
|
|
||||||
if (params.node.isRowPinned()) {
|
|
||||||
return params.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.dateFormat) {
|
|
||||||
return ZoneDateTimeFormatter.parseForTimeZoneAndFormat(params.value, this.defaultFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ZoneDateTimeFormatter.isValidFormat(this.dateFormat)) {
|
|
||||||
throw new Error('Invalid date format = ' + this.dateFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ZoneDateTimeFormatter.parseForTimeZoneAndFormat(params.value, this.dateFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static isValidFormat(format: string): boolean {
|
|
||||||
const validCharsRegex = /^[YyMmDdHhSsTZ.:()\[\] -]*$/;
|
|
||||||
return format && validCharsRegex.test(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static parseForTimeZoneAndFormat(value: string, dateFormat: string): string {
|
|
||||||
return DateTimeUtil.parseIsoDateTime(value).local().format(dateFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue