mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-07 21:07:20 +02:00
Code Cleanup
- Keep date formatting intact in arguments (necessary if the initial string contains optional information, as start or end of day).
This commit is contained in:
parent
ec330921de
commit
e9abac1d0f
2 changed files with 20 additions and 5 deletions
24
src/A3.cpp
24
src/A3.cpp
|
@ -694,9 +694,6 @@ const A3 A3::tokenize (const A3& input) const
|
|||
// List of operators for recognition.
|
||||
std::vector <std::string> operators = A3::operator_list ();
|
||||
|
||||
// Date format, for both parsing and rendering.
|
||||
std::string date_format = context.config.get ("dateformat");
|
||||
|
||||
// Nibble them apart.
|
||||
A3 output;
|
||||
Nibbler n (combined);
|
||||
|
@ -757,9 +754,9 @@ const A3 A3::tokenize (const A3& input) const
|
|||
// Must be higher than number.
|
||||
// Must be higher than operator.
|
||||
// Note that Nibbler::getDate does not read durations.
|
||||
else if (n.getDate (date_format, t))
|
||||
else if (is_date (n, s))
|
||||
{
|
||||
output.push_back (Arg (Date (t).toString (date_format), Arg::type_date, Arg::cat_literal));
|
||||
output.push_back (Arg (s, Arg::type_date, Arg::cat_literal));
|
||||
if (found_sequence)
|
||||
found_something_after_sequence = true;
|
||||
}
|
||||
|
@ -1569,6 +1566,23 @@ bool A3::is_dom (Nibbler& n, Arg& arg)
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool A3::is_date (Nibbler& n, std::string& result)
|
||||
{
|
||||
std::string date_format = context.config.get ("dateformat");
|
||||
std::string::size_type start = n.save ();
|
||||
time_t t;
|
||||
|
||||
if (n.getDate (date_format, t))
|
||||
{
|
||||
result = n.str ().substr (start, n.cursor () - start);
|
||||
return true;
|
||||
}
|
||||
|
||||
n.restore ();
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// A duration may only be followed by \0, ), +, -, *, / or ' '.
|
||||
//
|
||||
|
|
1
src/A3.h
1
src/A3.h
|
@ -79,6 +79,7 @@ public:
|
|||
static bool is_attribute (const std::string&, std::string&);
|
||||
static bool is_modifier (const std::string&, std::string&);
|
||||
static bool is_dom (Nibbler&, Arg&);
|
||||
static bool is_date (Nibbler&, std::string&);
|
||||
static bool is_duration (Nibbler&, std::string&);
|
||||
static bool is_pattern (Nibbler&, std::string&);
|
||||
static bool is_subst (Nibbler&, std::string&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue