forked from taozhi8833998/node-sql-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatetime.pegjs
More file actions
21 lines (19 loc) · 860 Bytes
/
datetime.pegjs
File metadata and controls
21 lines (19 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
timezone
= w:('WITHOUT'i / 'WITH'i) __ KW_TIME __ 'ZONE'i {
// => string[];
return [w.toUpperCase(), 'TIME', 'ZONE']
}
time_type
= t:(KW_TIME / KW_TIMESTAMP / KW_TIMESTAMPTZ / KW_TIMESTAMP_TZ / KW_TIMESTAMP_NTZ / KW_TIMESTAMP_LTZ) __ LPAREN __ l:[0-9]+ __ RPAREN __ tz:timezone? { return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true, suffix: tz }; }
/ t:(KW_TIME / KW_TIMESTAMP / KW_TIMESTAMPTZ / KW_TIMESTAMP_TZ / KW_TIMESTAMP_NTZ / KW_TIMESTAMP_LTZ) __ tz:timezone? { return { dataType: t, suffix: tz }; }
datetime_type
= t:(KW_DATE / KW_DATETIME / KW_YEAR) num:(__ LPAREN __ [0-6] __ RPAREN __ numeric_type_suffix?)? {
const result = { dataType: t }
if (num) {
result.length = parseInt(num[3], 10)
result.parentheses = true
result.suffix = num[7]
}
return result
}
/ time_type