GothenburgBitFactory / GothenburgBitFactory/taskwarrior
Durations/periods are not handled consistenly
- Dominant language
- C++
- Stars
- 6.1k
- Forks
- 423
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 11
Description
A duration or period may be ambiguous/vague, f.ex. 1 month may be 28/29/30/31 days. However when doing calculations on dates, taskwarrior will "normalise" a duration into seconds then add that to the date.
This can easily be verified with `task calc`, but it also applies to `task add due:...`.
```
task calc 2025-03-18+1mo
2025-04-17T01:00:00
```
This should be `2025-04-18T00:00:00`. I didn't plan this, but this also included a DST change, hence the extra unexpected hour difference in addition to the day difference.
Taskwarrior seems to handle this correctly in at least one place, recurrence. It is also well documented in [docs/durations](https://taskwarrior.org/docs/durations/)[^1]. However it doesn't behave like that everywhere.
[^1]: although it misses that 1 day is sometimes imprecise too due to DST.
In recurrence, it simply stores the period as a string and reparses it every time a template is created, taking into account the context of the date (`src/recur.cpp`). For all other locations it seems to convert to seconds first using some "arbitrary" value (i.e. 30 days in a month), and stores it as a single `time_t` field (`src/libshared/src/Duration`).
Contributor guide
Assessment
This issue has not been assessed yet.