- `Datetimee("tomorrow")` can create extra exclusion ahead of current time
which in turn create erroneous synthetic intervals
- Fixes#260
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
If there are escaped quotes in the tags database file, when the file is read,
then written, additional escape characters were inserted.
For example:
When tag 'a "test"' is written, it gets stored as 'a \"test\"'. Then it's read
back in that form, but the next time it's serialized to disk, the quotes would
be escaped again resulting in 'a \\"test\\"' which has the effect of removing
the escapes for the double-quotes.
Escapes the quotes for the annotations in the data file, and when
converting an interval to JSON.
The quotes in the annotations were already dequoted in
IntervalFactory::fromSerialization, so we only needed to quote the strings
when serializing or dumping to JSON.
datetime.timedelta stores days, seconds and microseconds. Therefore the
seconds attribute only stores timedeltas of less than 24 hours. Use
total_seconds() instead which properly accounts for the days part.
- somehow cpp-testfiles are not compiled when calling make in the test directory
- make install is required to be executed before make test, because we need access to man pages (help.t)
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
- `task delete` does add 'end' to modified JSON but not remove key 'start'
- Stop time tracking when task is deleted
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
- Update example JSONs
- Test only for active time tracking
- Test resulting intervals, not resulting output
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
When input data from taskwarrior (e.g. via bugwarrior) contains UTF-8-illegal characters, `on-modify.timewarrior` would fail:
```
Traceback (most recent call last):
File "$HOME/.task/hooks/on-modify.timewarrior", line 42, in <module>
old = json.loads(sys.stdin.readline())
File "/usr/lib/python3.6/codecs.py", line 321, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 1042: invalid continuation byte
```
This is fixed by manually decoding from stdin's underlying binary I/O object and replacing encoding errors with the Unicode replacement character [1].
[1]: https://docs.python.org/3/library/codecs.html#error-handlers
If the description contained multiple lines, it would be formatted as a
bytes object, including Python's `b""` marker for byte literals and any
newlines. This would then be passed literally to `timew`, which would
then choke on it, because it would record the newlines in its database.
This patch simply gets rid of the string join/split operations and the
encoding, which solves the issue.
Since we pass arrays instead of strings to `subprocess.call`, we are not
subject to command injection security vulnerabilities.
Fixes: 0b6dbf7e12
Fixes the following error with Python 3.6.8:
```
File "$HOME/.task/hooks/on-modify.timewarrior", line 33
from __future__ import print_function
SyntaxError: from __future__ imports must occur at the beginning of the file
```