mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
helper: Implemented minimalDelta to display minimal time diff strings
This commit is contained in:
parent
f70cf67f0f
commit
c01933116e
2 changed files with 28 additions and 0 deletions
|
@ -267,3 +267,30 @@ bool findHint (const CLI& cli, const std::string& hint)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string minimalDelta (const Datetime& left, const Datetime& right)
|
||||
{
|
||||
std::string result = right.toISOLocalExtended ();
|
||||
|
||||
if (left.sameYear (right))
|
||||
{
|
||||
result.replace (0, 5, " ");
|
||||
if (left.sameMonth (right))
|
||||
{
|
||||
result.replace (5, 3, " ");
|
||||
if (left.sameDay (right))
|
||||
{
|
||||
result.replace (8, 3, " ");
|
||||
if (left.sameHour (right))
|
||||
{
|
||||
result.replace (11, 3, " ");
|
||||
if (left.minute () == right.minute ())
|
||||
result.replace (14, 3, " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue