mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
CmdStart: Stop previous interval at given start time
- End time of previous open interval now set to start time given on cmd line in CmdStart.
This commit is contained in:
parent
3be4e442bf
commit
07e777b62c
2 changed files with 15 additions and 2 deletions
|
@ -45,8 +45,11 @@ int CmdStart (
|
|||
auto latest = getLatestInterval (database);
|
||||
if (latest.range.is_open ())
|
||||
{
|
||||
// Stop it.
|
||||
// Stop it, at the given start time, if applicable.
|
||||
Interval modified {latest};
|
||||
if (filter.range.start.toEpoch () != 0)
|
||||
modified.range.end = filter.range.start;
|
||||
else
|
||||
modified.range.end = Datetime ();
|
||||
|
||||
// Update database.
|
||||
|
|
10
test/start.t
10
test/start.t
|
@ -79,6 +79,16 @@ class TestStart(TestCase):
|
|||
self.assertIn("Recorded foo", out)
|
||||
self.assertIn("Tracking bar", out)
|
||||
|
||||
def test_start_with_open_interval_timed(self):
|
||||
"""Test timed start with already open interval, which should be auto-stopped
|
||||
at given datetime"""
|
||||
self.t("start 2016-01-01T00:00:00 foo")
|
||||
code, out, err = self.t("start 2016-01-01T01:00:00 bar")
|
||||
self.assertIn("Recorded foo", out)
|
||||
self.assertIn("Tracking bar", out)
|
||||
|
||||
self.assertIn("Ended 01:00:00",out)
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue