ISO8601: Added separate ::isoEnabled settings for ISO8601d and ISO8601p
This commit is contained in:
@@ -633,6 +633,7 @@ void Context::staticInitialization ()
|
|||||||
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
|
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||||
Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat");
|
Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat");
|
||||||
Lexer::isoEnabled = Variant::isoEnabled = config.getBoolean ("date.iso");
|
Lexer::isoEnabled = Variant::isoEnabled = config.getBoolean ("date.iso");
|
||||||
|
ISO8601p::isoEnabled = ISO8601d::isoEnabled = config.getBoolean ("date.iso");
|
||||||
|
|
||||||
TDB2::debug_mode = config.getBoolean ("debug");
|
TDB2::debug_mode = config.getBoolean ("debug");
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ static struct
|
|||||||
|
|
||||||
std::string ISO8601d::weekstart = STRING_DATE_SUNDAY;
|
std::string ISO8601d::weekstart = STRING_DATE_SUNDAY;
|
||||||
int ISO8601d::minimumMatchLength = 3;
|
int ISO8601d::minimumMatchLength = 3;
|
||||||
|
bool ISO8601d::isoEnabled = true;
|
||||||
|
bool ISO8601p::isoEnabled = true;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
ISO8601d::ISO8601d ()
|
ISO8601d::ISO8601d ()
|
||||||
@@ -233,13 +235,26 @@ bool ISO8601d::parse (
|
|||||||
{
|
{
|
||||||
auto i = start;
|
auto i = start;
|
||||||
Nibbler n (input.substr (i));
|
Nibbler n (input.substr (i));
|
||||||
if (parse_formatted (n, format) ||
|
if (parse_formatted (n, format))
|
||||||
parse_date_time (n) || // Strictest first.
|
{
|
||||||
parse_date_time_ext (n) ||
|
// Check the values and determine time_t.
|
||||||
parse_date_ext (n) ||
|
if (validate ())
|
||||||
parse_time_utc_ext (n) ||
|
{
|
||||||
parse_time_off_ext (n) ||
|
// Record cursor position.
|
||||||
parse_time_ext (n)) // Time last, as it is the most permissive.
|
start = n.cursor ();
|
||||||
|
|
||||||
|
resolve ();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (ISO8601d::isoEnabled &&
|
||||||
|
(parse_date_time (n) || // Strictest first.
|
||||||
|
parse_date_time_ext (n) ||
|
||||||
|
parse_date_ext (n) ||
|
||||||
|
parse_time_utc_ext (n) ||
|
||||||
|
parse_time_off_ext (n) ||
|
||||||
|
parse_time_ext (n))) // Time last, as it is the most permissive.
|
||||||
{
|
{
|
||||||
// Check the values and determine time_t.
|
// Check the values and determine time_t.
|
||||||
if (validate ())
|
if (validate ())
|
||||||
@@ -252,10 +267,10 @@ bool ISO8601d::parse (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ::parse_epoch and ::parse_named do not require ::validate and ::resolve.
|
|
||||||
else if (parse_epoch (n) ||
|
else if (parse_epoch (n) ||
|
||||||
parse_named (n))
|
parse_named (n))
|
||||||
{
|
{
|
||||||
|
// ::validate and ::resolve are not needed in this case.
|
||||||
start = n.cursor ();
|
start = n.cursor ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class ISO8601d
|
|||||||
public:
|
public:
|
||||||
static std::string weekstart;
|
static std::string weekstart;
|
||||||
static int minimumMatchLength;
|
static int minimumMatchLength;
|
||||||
|
static bool isoEnabled;
|
||||||
|
|
||||||
ISO8601d ();
|
ISO8601d ();
|
||||||
ISO8601d (const std::string&, const std::string& format = "");
|
ISO8601d (const std::string&, const std::string& format = "");
|
||||||
@@ -138,6 +139,8 @@ public:
|
|||||||
class ISO8601p
|
class ISO8601p
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static bool isoEnabled;
|
||||||
|
|
||||||
ISO8601p ();
|
ISO8601p ();
|
||||||
ISO8601p (time_t);
|
ISO8601p (time_t);
|
||||||
ISO8601p (const std::string&);
|
ISO8601p (const std::string&);
|
||||||
|
|||||||
Reference in New Issue
Block a user