OmniSciDB
a5dc49c757
|
#include <DateTimeParser.h>
Classes | |
struct | DateTime |
Public Types | |
enum | FormatType { FormatType::Date, FormatType::Time, FormatType::Timezone } |
Public Member Functions | |
std::optional< int64_t > | parse (std::string_view const, unsigned dim) |
void | setFormatType (FormatType) |
std::string_view | unparsed () const |
Private Member Functions | |
bool | parseWithFormat (std::string_view format, std::string_view &str) |
void | resetDateTime () |
bool | updateDateTimeAndStr (char const field, std::string_view &) |
Private Attributes | |
DateTime | dt_ |
FormatType | format_type_ |
std::string_view | unparsed_ |
Set format_type_ and parse date/time/timestamp strings into (s,ms,us,ns) since the epoch based on given dim in (0,3,6,9) respectively. Basic idea is to parse given string by matching to formats ("%Y-%m-%d", "%m/%d/%Y", ...) until a valid parse is found. Save parsed values into a DateTime dt_ struct from which the final epoch-based int64_t value is calculated.
Definition at line 55 of file DateTimeParser.h.
|
strong |
std::optional< int64_t > DateTimeParser::parse | ( | std::string_view const | str, |
unsigned | dim | ||
) |
Definition at line 244 of file DateTimeParser.cpp.
References dt_, format_type_, anonymous_namespace{DateTimeParser.cpp}::formatViews(), DateTimeParser::DateTime::getTime(), parseWithFormat(), and unparsed_.
Referenced by dateTimeParseOptional< kDATE >(), dateTimeParseOptional< kTIME >(), and dateTimeParseOptional< kTIMESTAMP >().
|
private |
Definition at line 219 of file DateTimeParser.cpp.
References anonymous_namespace{DateTimeParser.cpp}::eatSpace(), and updateDateTimeAndStr().
Referenced by parse().
|
private |
Definition at line 258 of file DateTimeParser.cpp.
References dt_.
Referenced by setFormatType().
void DateTimeParser::setFormatType | ( | FormatType | format_type | ) |
Definition at line 262 of file DateTimeParser.cpp.
References format_type_, and resetDateTime().
Referenced by dateTimeParseOptional< kDATE >(), dateTimeParseOptional< kTIME >(), and dateTimeParseOptional< kTIMESTAMP >().
std::string_view DateTimeParser::unparsed | ( | ) | const |
Definition at line 267 of file DateTimeParser.cpp.
References unparsed_.
Referenced by dateTimeParseOptional< kDATE >(), dateTimeParseOptional< kTIME >(), and dateTimeParseOptional< kTIMESTAMP >().
|
private |
Definition at line 273 of file DateTimeParser.cpp.
References cat(), DateTimeParser::DateTime::d, dt_, anonymous_namespace{DateTimeParser.cpp}::eatMonth(), DateTimeParser::DateTime::H, DateTimeParser::DateTime::m, DateTimeParser::DateTime::M, anonymous_namespace{DateTimeParser.cpp}::month_prefixes, DateTimeParser::DateTime::n, DateTimeParser::DateTime::p, anonymous_namespace{DateTimeParser.cpp}::pow_10, DateTimeParser::DateTime::S, DateTimeParser::DateTime::Y, and DateTimeParser::DateTime::z.
Referenced by parseWithFormat().
|
private |
Definition at line 78 of file DateTimeParser.h.
Referenced by parse(), resetDateTime(), and updateDateTimeAndStr().
|
private |
Definition at line 79 of file DateTimeParser.h.
Referenced by parse(), and setFormatType().
|
private |
Definition at line 80 of file DateTimeParser.h.
Referenced by parse(), and unparsed().