mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
ISO8601d: ::parse_named can also skip ::validate and ::resolve
This commit is contained in:
parent
7641a86f23
commit
abbebf69ad
2 changed files with 36 additions and 33 deletions
|
@ -103,32 +103,33 @@ static void midsommarafton (struct tm* t)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// <day>
|
// Note how these are all single words:
|
||||||
// <month>
|
// <day>
|
||||||
// Nth
|
// <month>
|
||||||
// socy, eocy
|
// Nth
|
||||||
// socq, eocq
|
// socy, eocy
|
||||||
// socm, eocm
|
// socq, eocq
|
||||||
// som, eom
|
// socm, eocm
|
||||||
// soq, eoq
|
// som, eom
|
||||||
// soy, eoy
|
// soq, eoq
|
||||||
// socw, eocw
|
// soy, eoy
|
||||||
// sow, eow
|
// socw, eocw
|
||||||
// soww, eoww
|
// sow, eow
|
||||||
// sod, eod
|
// soww, eoww
|
||||||
// yesterday
|
// sod, eod
|
||||||
// today
|
// yesterday
|
||||||
// now
|
// today
|
||||||
// tomorrow
|
// now
|
||||||
// later = midnight, Jan 18th, 2038.
|
// tomorrow
|
||||||
// someday = midnight, Jan 18th, 2038.
|
// later = midnight, Jan 18th, 2038.
|
||||||
// easter
|
// someday = midnight, Jan 18th, 2038.
|
||||||
// eastermonday
|
// easter
|
||||||
// ascension
|
// eastermonday
|
||||||
// pentecost
|
// ascension
|
||||||
// goodfriday
|
// pentecost
|
||||||
// midsommar = midnight, 1st Saturday after 20th June
|
// goodfriday
|
||||||
// midsommarafton = midnight, 1st Friday after 19th June
|
// midsommar = midnight, 1st Saturday after 20th June
|
||||||
|
// midsommarafton = midnight, 1st Friday after 19th June
|
||||||
//
|
//
|
||||||
bool namedDates (const std::string& name, Variant& value)
|
bool namedDates (const std::string& name, Variant& value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -239,8 +239,7 @@ bool ISO8601d::parse (
|
||||||
parse_date_ext (n) ||
|
parse_date_ext (n) ||
|
||||||
parse_time_utc_ext (n) ||
|
parse_time_utc_ext (n) ||
|
||||||
parse_time_off_ext (n) ||
|
parse_time_off_ext (n) ||
|
||||||
parse_time_ext (n) || // Time last, as it is the most permissive.
|
parse_time_ext (n)) // Time last, as it is the most permissive.
|
||||||
parse_named (n))
|
|
||||||
{
|
{
|
||||||
// Check the values and determine time_t.
|
// Check the values and determine time_t.
|
||||||
if (validate ())
|
if (validate ())
|
||||||
|
@ -253,8 +252,9 @@ bool ISO8601d::parse (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ::parse_epoch doesn't require ::validate and ::resolve.
|
// ::parse_epoch and ::parse_named do not require ::validate and ::resolve.
|
||||||
else if (parse_epoch (n))
|
else if (parse_epoch (n) ||
|
||||||
|
parse_named (n))
|
||||||
{
|
{
|
||||||
start = n.cursor ();
|
start = n.cursor ();
|
||||||
return true;
|
return true;
|
||||||
|
@ -575,14 +575,16 @@ bool ISO8601d::parse_formatted (Nibbler& n, const std::string& format)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
bool ISO8601d::parse_named (Nibbler& n)
|
bool ISO8601d::parse_named (Nibbler& n)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
Variant v;
|
Variant v;
|
||||||
if (namedDates (input, v))
|
if (namedDates (n.str ().substr (n.cursor ()), v))
|
||||||
{
|
{
|
||||||
|
// Advance n by the length of the found item.
|
||||||
|
std::string dummy;
|
||||||
|
n.getUntilEOS (dummy);
|
||||||
|
|
||||||
_date = v.get_date ();
|
_date = v.get_date ();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue