Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(state.tableProps.columns || []).forEach(column => {
if (column.id === 'ccc') {
column.name = ['Date', 'only'];
column.type = ColumnType.Datetime;
column.validation = { allow_YY: true };
(state.tableProps.data || []).forEach((row, i) => {
const d = new Date(Date.UTC(2018, 0, 1));
// three day increment
d.setUTCDate(3 * i + 1);
// date only
row.ccc = d.toISOString().substr(0, 10);
});
} else if (column.id === 'ddd') {
column.name = ['Date', 'with', 'time'];
column.type = ColumnType.Datetime;
(state.tableProps.data || []).forEach((row, i) => {
const d = new Date(Date.UTC(2018, 0, 1));
// two hours and 11 seconds increment
d.setUTCSeconds(i * 7211);
// datetime ending with seconds
function getValidator(c: Options): (value: any, c?: any) => IReconciliation {
switch (c.type) {
case ColumnType.Numeric:
return validateNumber;
case ColumnType.Text:
return validateText;
case ColumnType.Datetime:
return validateDate;
case ColumnType.Any:
default:
return reconcileAny;
}
}
function getImplicitLexeme(type: ColumnType = ColumnType.Any): ILexemeResult {
switch (type) {
case ColumnType.Any:
case ColumnType.Text:
return {
lexeme: boundLexeme(contains),
value: RelationalOperator.Contains
};
case ColumnType.Datetime:
return {
lexeme: boundLexeme(dateStartsWith),
value: RelationalOperator.DateStartsWith
};
case ColumnType.Numeric:
return {
lexeme: boundLexeme(equal),
value: RelationalOperator.Equal
};
}
}