GothenburgBitFactory / timewarrior

Timewarrior - Commandline Time Tracking and Reporting
https://timewarrior.net
MIT License
1.26k stars 95 forks source link

timew started acting up :( #524

Closed rafalkrupinski closed 1 year ago

rafalkrupinski commented 1 year ago

Hello team!

I really like the simple interface and philosophy of timewarrior. Unfortunately lately something's wrong with it.

I think the problem started with the new year. I've been using it since the last December.

I'm on Debian 11 Tried with python 3.11.0, 3.10.8 and 3.9.15

$ timew start admin
Note: 'admin' is a new tag.
Tracking admin
  Started 2023-01-09T10:36:36
  Current                  36
  Total               0:00:00

$ timew stop
The end of a date range must be after the start.

$ timew summary
timew: /build/timew-6opSjv/timew-1.4.2+ds.1/src/Range.cpp:359: time_t Range::total() const: Assertion `is_open () || end >= start' failed.
Aborted

$ timew --version
1.4.2

$ python --version
Python 3.10.8

$ cat .timewarrior/timewarrior.cfg 
import /home/user/.timewarrior/dark_green.theme
matte@vanadium:~$

$
lauft commented 1 year ago

Can you try version 1.4.3, which is the latest release?

To debug further, you can try to call your command with the :debug hint, which may give some more insights... 🤞🏻

rafalkrupinski commented 1 year ago

Didn't make it to build the new version, but it works now, so I can't check it anyway :/

I'll try :debug the next time

rafalkrupinski commented 1 year ago

It seems that it crashes when the task start time is after the current time when ending the task. It happens because the system time is wrong when I start a task shortly after waking up the laptop, then the time gets fixed and then I can't stop a task

$ timew summary
timew: /build/timew-6opSjv/timew-1.4.2+ds.1/src/Range.cpp:359: time_t Range::total() const: Assertion `is_open () || end >= start' failed.
Aborted

$ timew summary :debug
CLI Parser
  _original_args
    timew summary :debug
  _args
    word basename='timew' raw='timew' BINARY 
    word canonical='summary' raw='summary' ORIGINAL EXT 
    word canonical=':debug' raw=':debug' ORIGINAL HINT FILTER 

>> 2023-03.data: 46 intervals
>> Found 0 holidays
>> Found 0 exclusions
>> Loaded 5 tracked intervals
timew: /build/timew-6opSjv/timew-1.4.2+ds.1/src/Range.cpp:359: time_t Range::total() const: Assertion `is_open () || end >= start' failed.
Aborted
$ date
mon, 13 mar 2023, 09:57:56 CET   # <--- 08:57:56 in UTC
$ tail -n1 .timewarrior/data/2023-03.data
inc 20230313T090401Z # infra
sruffell commented 1 year ago

It happens because the system time is wrong when I start a task shortly after waking up the laptop, then the time gets fixed and then I can't stop a task

I think you should be able to modify the start time when this happens with the timew modify command. For example, below I started an interval, then moved it forward by modifying the data file, then "fixed" it with the modify command:

% timew start
Tracking
  Started 2023-03-13T07:38:19
  Current                  19
  Total               0:00:00
% cat /tmp/timewarrior/data/2023-03.data
inc 20230313T123819Z
% sed -i -e 's|20230313T123819Z|20230313T143819Z|' /tmp/timewarrior/data/2023-03.data
% timew stop
The end of a date range must be after the start.
% timew export @1
[
{"id":1,"start":"20230313T143819Z"}
]
% timew modify start @1 2023-03-13T07:00:00
% timew stop
Recorded
  Started 2023-03-13T07:00:00
  Ended                 40:13
  Total               0:40:13

Although, I do agree the error message could be a little more helpful about which date is after which one...