mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Lexer: Migrated from Date to ISO8601d
This commit is contained in:
parent
26fbca7896
commit
7641a86f23
1 changed files with 2 additions and 20 deletions
|
@ -28,7 +28,6 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
#include <ISO8601.h>
|
#include <ISO8601.h>
|
||||||
#include <Date.h>
|
|
||||||
#include <utf8.h>
|
#include <utf8.h>
|
||||||
|
|
||||||
static const std::string uuid_pattern = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
|
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
|
// Lexer::Type::date
|
||||||
// <ISO8601d> | <Date>
|
// <ISO8601d>
|
||||||
bool Lexer::isDate (std::string& token, Lexer::Type& type)
|
bool Lexer::isDate (std::string& token, Lexer::Type& type)
|
||||||
{
|
{
|
||||||
// Try an ISO date parse.
|
// Try an ISO date parse.
|
||||||
|
@ -440,7 +439,7 @@ bool Lexer::isDate (std::string& token, Lexer::Type& type)
|
||||||
{
|
{
|
||||||
std::size_t iso_i = 0;
|
std::size_t iso_i = 0;
|
||||||
ISO8601d iso;
|
ISO8601d iso;
|
||||||
if (iso.parse (_text.substr (_cursor), iso_i))
|
if (iso.parse (_text.substr (_cursor), iso_i, Lexer::dateFormat))
|
||||||
{
|
{
|
||||||
type = Lexer::Type::date;
|
type = Lexer::Type::date;
|
||||||
token = _text.substr (_cursor, iso_i);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue