mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Variant: Migrated from Date to ISO8601d
This commit is contained in:
parent
d4abae0f70
commit
b1d2d6d5e8
2 changed files with 15 additions and 20 deletions
|
@ -633,7 +633,6 @@ 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");
|
||||||
ISO8601p::isoEnabled = ISO8601d::isoEnabled = config.getBoolean ("date.iso");
|
ISO8601p::isoEnabled = ISO8601d::isoEnabled = config.getBoolean ("date.iso");
|
||||||
Variant::isoEnabled = config.getBoolean ("date.iso");
|
|
||||||
|
|
||||||
TDB2::debug_mode = config.getBoolean ("debug");
|
TDB2::debug_mode = config.getBoolean ("debug");
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
std::string Variant::dateFormat = "";
|
std::string Variant::dateFormat = "";
|
||||||
bool Variant::searchCaseSensitive = true;
|
bool Variant::searchCaseSensitive = true;
|
||||||
bool Variant::searchUsingRegex = true;
|
bool Variant::searchUsingRegex = true;
|
||||||
bool Variant::isoEnabled = true;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Variant::Variant ()
|
Variant::Variant ()
|
||||||
|
@ -1010,8 +1009,8 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_date:
|
case type_date:
|
||||||
{
|
{
|
||||||
left.cast (type_date);
|
left.cast (type_date);
|
||||||
Date left_date (left._date);
|
ISO8601d left_date (left._date);
|
||||||
Date right_date (right._date);
|
ISO8601d right_date (right._date);
|
||||||
return left_date.sameDay (right_date);
|
return left_date.sameDay (right_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1031,8 +1030,8 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_date:
|
case type_date:
|
||||||
{
|
{
|
||||||
left.cast (type_date);
|
left.cast (type_date);
|
||||||
Date left_date (left._date);
|
ISO8601d left_date (left._date);
|
||||||
Date right_date (right._date);
|
ISO8601d right_date (right._date);
|
||||||
return left_date.sameDay (right_date);
|
return left_date.sameDay (right_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,8 +1056,8 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_date:
|
case type_date:
|
||||||
{
|
{
|
||||||
left.cast (type_date);
|
left.cast (type_date);
|
||||||
Date left_date (left._date);
|
ISO8601d left_date (left._date);
|
||||||
Date right_date (right._date);
|
ISO8601d right_date (right._date);
|
||||||
return left_date.sameDay (right_date);
|
return left_date.sameDay (right_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1100,8 +1099,8 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_date:
|
case type_date:
|
||||||
{
|
{
|
||||||
left.cast (type_date);
|
left.cast (type_date);
|
||||||
Date left_date (left._date);
|
ISO8601d left_date (left._date);
|
||||||
Date right_date (right._date);
|
ISO8601d right_date (right._date);
|
||||||
return left_date.sameDay (right_date);
|
return left_date.sameDay (right_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1123,8 +1122,8 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
case type_duration:
|
case type_duration:
|
||||||
{
|
{
|
||||||
right.cast (type_date);
|
right.cast (type_date);
|
||||||
Date left_date (left._date);
|
ISO8601d left_date (left._date);
|
||||||
Date right_date (right._date);
|
ISO8601d right_date (right._date);
|
||||||
return left_date.sameDay (right_date);
|
return left_date.sameDay (right_date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1933,30 +1932,27 @@ void Variant::cast (const enum type new_type)
|
||||||
case type_date:
|
case type_date:
|
||||||
{
|
{
|
||||||
_date = 0;
|
_date = 0;
|
||||||
|
|
||||||
ISO8601d iso;
|
ISO8601d iso;
|
||||||
std::string::size_type pos = 0;
|
std::string::size_type pos = 0;
|
||||||
if (isoEnabled &&
|
if (iso.parse (_string, pos, dateFormat) &&
|
||||||
iso.parse (_string, pos) &&
|
|
||||||
pos == _string.length ())
|
pos == _string.length ())
|
||||||
{
|
{
|
||||||
_date = (time_t) iso;
|
_date = iso.toEpoch ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
ISO8601p isop;
|
ISO8601p isop;
|
||||||
if (isoEnabled &&
|
if (isop.parse (_string, pos) &&
|
||||||
isop.parse (_string, pos) &&
|
|
||||||
pos == _string.length ())
|
pos == _string.length ())
|
||||||
{
|
{
|
||||||
_date = Date ().toEpoch () + (time_t) isop;
|
_date = ISO8601d ().toEpoch () + (time_t) isop;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dateFormat != "")
|
if (dateFormat != "")
|
||||||
{
|
{
|
||||||
_date = Date (_string, dateFormat).toEpoch ();
|
_date = ISO8601d (_string, dateFormat).toEpoch ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue