1 | #include <stddef.h> |
2 | #include <time.h> |
3 | |
4 | #include <Core/Types.h> |
5 | |
6 | class DateLUTImpl; |
7 | |
8 | namespace DB |
9 | { |
10 | |
11 | class ReadBuffer; |
12 | |
13 | /** https://xkcd.com/1179/ |
14 | * |
15 | * The existence of this function is an example of bad practice |
16 | * and contradicts our development principles. |
17 | * |
18 | * This function will recognize the following patterns: |
19 | * |
20 | * NNNNNNNNNN - 9..10 digits is a unix timestamp |
21 | * |
22 | * YYYYMMDDhhmmss - 14 numbers is always interpreted this way |
23 | * |
24 | * YYYYMMDD - 8 digits in a row |
25 | * YYYY*MM*DD - or with any delimiter after first 4-digit year component and after month. |
26 | * |
27 | * DD/MM/YY |
28 | * DD/MM/YYYY - when '/' separator is used, these are the only possible forms |
29 | * Note that American style is not supported. |
30 | * |
31 | * hh:mm:ss - when ':' separator is used, it is always time |
32 | * hh:mm - it can be specified without seconds |
33 | * |
34 | * YYYY - 4 digits is always year |
35 | * |
36 | * YYYYMM - 6 digits is a year, month if year was not already read |
37 | * hhmmss - 6 digits is a time if year was already read |
38 | * |
39 | * .nnnnnnn - any number of digits after point is fractional part of second, if it is not YYYY.MM.DD or DD.MM.YYYY |
40 | * |
41 | * T - means that time will follow |
42 | * |
43 | * Z - means zero UTC offset |
44 | * |
45 | * +hhmm |
46 | * +hh:mm |
47 | * +hh |
48 | * -... - time zone offset |
49 | * |
50 | * single whitespace can be used as a separator |
51 | * |
52 | * AM/PM - AM is ignored and PM means: add 12 hours if value is less than 12. |
53 | * |
54 | * Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec - allowed to specify month |
55 | * Mon/Tue/Wed/Thu/Fri/Sat/Sun - simply ignored. |
56 | */ |
57 | |
58 | void parseDateTimeBestEffort(time_t & res, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone); |
59 | bool tryParseDateTimeBestEffort(time_t & res, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone); |
60 | void parseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone); |
61 | bool tryParseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone); |
62 | |
63 | } |
64 | |