mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdStop: Refactored data I/O
This commit is contained in:
parent
b6e5ded895
commit
6965b506e8
1 changed files with 5 additions and 4 deletions
|
@ -38,19 +38,20 @@ int CmdStop (
|
||||||
Database& database)
|
Database& database)
|
||||||
{
|
{
|
||||||
// Load the most recent interval.
|
// Load the most recent interval.
|
||||||
auto latest = database.getLatestInterval ();
|
auto latest = getLatestInterval (database);
|
||||||
|
|
||||||
// Verify the interval is open.
|
// Verify the interval is open.
|
||||||
if ( latest.isStarted () &&
|
if ( latest.isStarted () &&
|
||||||
! latest.isEnded ())
|
! latest.isEnded ())
|
||||||
{
|
{
|
||||||
// Stop it.
|
// Stop it.
|
||||||
latest.end (Datetime ());
|
auto modified {latest};
|
||||||
database.modifyInterval (latest);
|
modified.end (Datetime ());
|
||||||
|
database.modifyInterval (latest, modified);
|
||||||
|
|
||||||
// User feedback.
|
// User feedback.
|
||||||
if (rules.getBoolean ("verbose"))
|
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
|
// If tags were specified, and after removing those tags, there are still
|
||||||
// tags remaining, then add a contiguous interval.
|
// tags remaining, then add a contiguous interval.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue