Skip to content
This repository was archived by the owner on Mar 30, 2026. It is now read-only.
This repository was archived by the owner on Mar 30, 2026. It is now read-only.

fix overlapping events when editing new period #315

@leo-b

Description

@leo-b

Hi!

I am using the Edit Events -> New Period feature to subsequently add periods inside existing working days.

Unfortunately this doesn't produce the expected results if the newly inserted period overlaps with existing tasks.
IN and OUT events of existing overlapping tasks are simply not modified.
This is a bug because it corrupts the data:

  • If a new period with a different Task-id is inserted and the OUT event of the previously existing task is inside that period, it will erroneously end the new period because OUT events have no task-id and the old OUT it will be interpreted as the end of the new task. Furthermore the timespan following the old OUT event will be without any assigned task.
  • If a new period with a different Task-id is inserted and the IN event of the previously existing task is inside that period, it will also end the newly inserted period and start the old task (possibly with a different task-id). The OUT event of the new period will possibly end any other existing task.

The proposed correct behavior (when processing existing events inside the new period in chronological order) would be:

  • If an existing OUT event is inside the new period:

    • if the OUT event ends a task with a different task-id, the existing event should be removed. Since there are no overlapping tasks in trackworktime, ther new IN event will autoatically end the previous task.
    • if the OUT event ends a task with the same task-id, the existing OUT event and the new IN event should be omitted, because the newly added period extends the existing task. (Existing hints attached to the previously existing task will be kept because they are stored with the old IN event. Maybe hints added to the new period should be appended to an existing hint?)
  • If an existing IN event is inside the new period:

    • If the corresponding OUT event is also inside the new period: remove both events. (The whole existing task was inside the new period and trackworktime doesn't allow overlapping tasks, so it is completely overwritten.)
    • If the corresponding OUT event is outside the new period:
      • If the new task-id matches the old task: The new period extends the existing task. Remove the existing IN event and omit the existing OUT event. (The OUT event of the existing task will automatically end the extended task.) (Maybe existing hints stored withe the removed IN event should be appeded to any new hints?)
      • If the new task-id is different from the existing task: The new period cuts some time off the existing task. Modify the existing IN event to the end of the newly inserted period. Omit the OUT event of the new period, since the moved IN event will already end the new task.

Maybe a (configurable) warning should be shown if editing a new period modifies existing tasks.

Cheers,
--leo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions