helper: Implemented minimalDelta to display minimal time diff strings

This commit is contained in:
Paul Beckingham 2016-05-30 15:09:45 -04:00
parent f70cf67f0f
commit c01933116e
2 changed files with 28 additions and 0 deletions

View file

@ -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;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -72,6 +72,7 @@ std::map <std::string, Color> createTagColorMap (const Rules&, Palette&, const s
int quantizeTo15Minutes (const int);
bool dayIsHoliday (const Rules&, const Datetime&);
bool findHint (const CLI&, const std::string&);
std::string minimalDelta (const Datetime&, const Datetime&);
// log.cpp
void enableDebugMode (bool);