2018-02-11 04:09:02 +00:00
|
|
|
#include <stddef.h>
|
2018-02-14 17:27:14 +00:00
|
|
|
#include <time.h>
|
2018-02-11 04:09:02 +00:00
|
|
|
|
2019-10-12 07:03:38 +00:00
|
|
|
#include <Core/Types.h>
|
|
|
|
|
2018-02-11 04:09:02 +00:00
|
|
|
class DateLUTImpl;
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ReadBuffer;
|
|
|
|
|
2018-02-12 00:55:46 +00:00
|
|
|
/** https://xkcd.com/1179/
|
|
|
|
*
|
|
|
|
* The existence of this function is an example of bad practice
|
|
|
|
* and contradicts our development principles.
|
|
|
|
*
|
|
|
|
* This function will recognize the following patterns:
|
2018-02-11 04:09:02 +00:00
|
|
|
*
|
|
|
|
* NNNNNNNNNN - 9..10 digits is a unix timestamp
|
|
|
|
*
|
|
|
|
* YYYYMMDDhhmmss - 14 numbers is always interpreted this way
|
|
|
|
*
|
|
|
|
* YYYYMMDD - 8 digits in a row
|
2018-02-12 00:55:46 +00:00
|
|
|
* YYYY*MM*DD - or with any delimiter after first 4-digit year component and after month.
|
2018-02-11 04:09:02 +00:00
|
|
|
*
|
|
|
|
* DD/MM/YY
|
|
|
|
* DD/MM/YYYY - when '/' separator is used, these are the only possible forms
|
|
|
|
* Note that American style is not supported.
|
|
|
|
*
|
|
|
|
* hh:mm:ss - when ':' separator is used, it is always time
|
|
|
|
* hh:mm - it can be specified without seconds
|
|
|
|
*
|
|
|
|
* YYYY - 4 digits is always year
|
|
|
|
*
|
|
|
|
* YYYYMM - 6 digits is a year, month if year was not already read
|
|
|
|
* hhmmss - 6 digits is a time if year was already read
|
|
|
|
*
|
2018-12-24 18:28:41 +00:00
|
|
|
* .nnnnnnn - any number of digits after point is fractional part of second, if it is not YYYY.MM.DD or DD.MM.YYYY
|
2018-02-11 04:09:02 +00:00
|
|
|
*
|
|
|
|
* T - means that time will follow
|
|
|
|
*
|
|
|
|
* Z - means zero UTC offset
|
|
|
|
*
|
|
|
|
* +hhmm
|
|
|
|
* +hh:mm
|
|
|
|
* +hh
|
|
|
|
* -... - time zone offset
|
|
|
|
*
|
|
|
|
* single whitespace can be used as a separator
|
|
|
|
*
|
2018-02-12 00:55:46 +00:00
|
|
|
* AM/PM - AM is ignored and PM means: add 12 hours if value is less than 12.
|
2018-02-11 04:09:02 +00:00
|
|
|
*
|
2018-02-12 00:55:46 +00:00
|
|
|
* Jan/Feb/Mar/Apr/May/Jun/Jul/Aug/Sep/Oct/Nov/Dec - allowed to specify month
|
|
|
|
* Mon/Tue/Wed/Thu/Fri/Sat/Sun - simply ignored.
|
2018-02-11 04:09:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
void parseDateTimeBestEffort(time_t & res, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone);
|
|
|
|
bool tryParseDateTimeBestEffort(time_t & res, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone);
|
2019-10-12 07:03:38 +00:00
|
|
|
void parseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone);
|
|
|
|
bool tryParseDateTime64BestEffort(DateTime64 & res, UInt32 scale, ReadBuffer & in, const DateLUTImpl & local_time_zone, const DateLUTImpl & utc_time_zone);
|
2018-02-11 04:09:02 +00:00
|
|
|
|
|
|
|
}
|