CmdStop: Refactored data I/O

This commit is contained in:
Paul Beckingham 2016-04-11 08:25:48 -04:00
parent b6e5ded895
commit 6965b506e8

View file

@ -38,19 +38,20 @@ int CmdStop (
Database& database)
{
// Load the most recent interval.
auto latest = database.getLatestInterval ();
auto latest = getLatestInterval (database);
// Verify the interval is open.
if ( latest.isStarted () &&
! latest.isEnded ())
{
// Stop it.
latest.end (Datetime ());
database.modifyInterval (latest);
auto modified {latest};
modified.end (Datetime ());
database.modifyInterval (latest, modified);
// User feedback.
if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (rules, latest);
std::cout << intervalSummarize (rules, modified);
// If tags were specified, and after removing those tags, there are still
// tags remaining, then add a contiguous interval.