/
getDate.ts
82 lines (81 loc) · 2.19 KB
/
getDate.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { FieldType } from '@terascope/types';
import { getDate } from '@terascope/utils';
import {
ProcessMode, FunctionDefinitionType, FunctionDefinitionCategory, FieldTransformConfig
} from '../interfaces';
export const getDateConfig: FieldTransformConfig = {
name: 'getDate',
type: FunctionDefinitionType.FIELD_TRANSFORM,
process_mode: ProcessMode.INDIVIDUAL_VALUES,
category: FunctionDefinitionCategory.DATE,
description: 'Returns the day of the month of the input date time',
examples: [
{
args: {},
config: {
version: 1,
fields: { testField: { type: FieldType.String } }
},
field: 'testField',
input: '2021-05-11T10:12:41.091Z',
output: 11
},
{
args: {},
config: {
version: 1,
fields: { testField: { type: FieldType.Date } }
},
field: 'testField',
input: new Date('2021-05-16T10:59:19.091Z'),
output: 16
},
{
args: {},
config: {
version: 1,
fields: { testField: { type: FieldType.String } }
},
field: 'testField',
input: '05/22/2021 EST',
output: 22
},
{
args: {},
config: {
version: 1,
fields: { testField: { type: FieldType.Number } }
},
field: 'testField',
input: 1510123223231,
output: 8
},
{
args: {},
config: {
version: 1,
fields: { testField: { type: FieldType.Date } }
},
field: 'testField',
input: [1621026300000, -420],
output: 14,
test_only: true,
}
],
create() {
return getDate;
},
accepts: [
FieldType.Date,
FieldType.String,
FieldType.Number
],
output_type({ field_config }) {
return {
field_config: {
...field_config,
type: FieldType.Number
}
};
}
};