Throw error message if start date is earlier than open interval

Closes #240

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
Thomas Lauf 2019-08-02 17:54:08 +02:00
parent a62ebf0196
commit 57f9982fd1
2 changed files with 25 additions and 1 deletions

View file

@ -35,7 +35,6 @@ int CmdStart (
Database& database,
Journal& journal)
{
// Add a new open interval, which may have a defined start time.
auto filter = getFilter (cli);
auto now = Datetime ();
@ -63,9 +62,18 @@ int CmdStart (
// Stop it, at the given start time, if applicable.
Interval modified {latest};
if (filter.start.toEpoch () != 0)
{
if (modified.start >= filter.start)
{
throw std::string ("The end of a date range must be after the start.");
}
modified.end = filter.start;
}
else
{
modified.end = Datetime ();
}
// Update database.
database.deleteInterval (latest);