Lexer: Migrated from Date to ISO8601d

This commit is contained in:
Paul Beckingham 2015-10-03 19:37:30 -04:00
parent 26fbca7896
commit 7641a86f23

View file

@ -28,7 +28,6 @@
#include <ctype.h>
#include <Lexer.h>
#include <ISO8601.h>
#include <Date.h>
#include <utf8.h>
static const std::string uuid_pattern = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
@ -432,7 +431,7 @@ bool Lexer::isString (std::string& token, Lexer::Type& type, const std::string&
////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::date
// <ISO8601d> | <Date>
// <ISO8601d>
bool Lexer::isDate (std::string& token, Lexer::Type& type)
{
// Try an ISO date parse.
@ -440,7 +439,7 @@ bool Lexer::isDate (std::string& token, Lexer::Type& type)
{
std::size_t iso_i = 0;
ISO8601d iso;
if (iso.parse (_text.substr (_cursor), iso_i))
if (iso.parse (_text.substr (_cursor), iso_i, Lexer::dateFormat))
{
type = Lexer::Type::date;
token = _text.substr (_cursor, iso_i);
@ -449,23 +448,6 @@ bool Lexer::isDate (std::string& token, Lexer::Type& type)
}
}
// Try a legacy rc.dateformat parse here.
if (Lexer::dateFormat != "")
{
try
{
std::size_t legacy_i = 0;
Date legacyDate (_text.substr (_cursor), legacy_i, Lexer::dateFormat, false, false);
type = Lexer::Type::date;
token = _text.substr (_cursor, legacy_i);
_cursor += legacy_i;
return true;
}
catch (...) { /* Never mind. */ }
}
return false;
}