mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
ISO8601: Added separate ::isoEnabled settings for ISO8601d and ISO8601p
This commit is contained in:
parent
9adfddfe65
commit
61e494195a
3 changed files with 27 additions and 8 deletions
|
@ -633,6 +633,7 @@ void Context::staticInitialization ()
|
|||
Task::regex = Variant::searchUsingRegex = config.getBoolean ("regex");
|
||||
Lexer::dateFormat = Variant::dateFormat = config.get ("dateformat");
|
||||
Lexer::isoEnabled = Variant::isoEnabled = config.getBoolean ("date.iso");
|
||||
ISO8601p::isoEnabled = ISO8601d::isoEnabled = config.getBoolean ("date.iso");
|
||||
|
||||
TDB2::debug_mode = config.getBoolean ("debug");
|
||||
|
||||
|
|
|
@ -112,6 +112,8 @@ static struct
|
|||
|
||||
std::string ISO8601d::weekstart = STRING_DATE_SUNDAY;
|
||||
int ISO8601d::minimumMatchLength = 3;
|
||||
bool ISO8601d::isoEnabled = true;
|
||||
bool ISO8601p::isoEnabled = true;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ISO8601d::ISO8601d ()
|
||||
|
@ -233,13 +235,26 @@ bool ISO8601d::parse (
|
|||
{
|
||||
auto i = start;
|
||||
Nibbler n (input.substr (i));
|
||||
if (parse_formatted (n, format) ||
|
||||
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.
|
||||
if (parse_formatted (n, format))
|
||||
{
|
||||
// Check the values and determine time_t.
|
||||
if (validate ())
|
||||
{
|
||||
// Record cursor position.
|
||||
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.
|
||||
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) ||
|
||||
parse_named (n))
|
||||
{
|
||||
// ::validate and ::resolve are not needed in this case.
|
||||
start = n.cursor ();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class ISO8601d
|
|||
public:
|
||||
static std::string weekstart;
|
||||
static int minimumMatchLength;
|
||||
static bool isoEnabled;
|
||||
|
||||
ISO8601d ();
|
||||
ISO8601d (const std::string&, const std::string& format = "");
|
||||
|
@ -138,6 +139,8 @@ public:
|
|||
class ISO8601p
|
||||
{
|
||||
public:
|
||||
static bool isoEnabled;
|
||||
|
||||
ISO8601p ();
|
||||
ISO8601p (time_t);
|
||||
ISO8601p (const std::string&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue