mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Move validation of filter range up
- Use default range starting at `now` - Add check for no datetime given (rare case of e.g. `timew stop :all`) Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
990e0772d0
commit
5b1c77b8aa
1 changed files with 11 additions and 1 deletions
|
@ -48,9 +48,10 @@ int CmdStop (
|
||||||
Journal& journal)
|
Journal& journal)
|
||||||
{
|
{
|
||||||
const bool verbose = rules.getBoolean ("verbose");
|
const bool verbose = rules.getBoolean ("verbose");
|
||||||
|
const Datetime now {};
|
||||||
|
|
||||||
|
auto filter = cli.getFilter ({ now, 0 });
|
||||||
// Load the most recent interval.
|
// Load the most recent interval.
|
||||||
auto filter = cli.getFilter ();
|
|
||||||
auto latest = getLatestInterval (database);
|
auto latest = getLatestInterval (database);
|
||||||
|
|
||||||
// Verify the interval is open.
|
// Verify the interval is open.
|
||||||
|
@ -66,6 +67,15 @@ int CmdStop (
|
||||||
"Perhaps you want the modify command?.");
|
"Perhaps you want the modify command?.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! filter.is_started())
|
||||||
|
{
|
||||||
|
throw std::string ("No datetime specified.");
|
||||||
|
}
|
||||||
|
else if (filter.start <= latest.start)
|
||||||
|
{
|
||||||
|
throw std::string ("The end of a date range must be after the start.");
|
||||||
|
}
|
||||||
|
|
||||||
journal.startTransaction ();
|
journal.startTransaction ();
|
||||||
|
|
||||||
Interval modified {latest};
|
Interval modified {latest};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue