Make dive::when private as first step for "timezone" support by bstoeger · Pull Request #4690 · subsurface/subsurface

Access the time of the dive via accessor functions, which make
it clear that they access the local time.

This will make it easier to audit changes when we start storing
time-offset data.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In multiple places, we set the time of the dive and the first dc.
Notably on import. Thus, add a function that does both.

Interestingly, if a dc has the same time as the dive, this time
will not be written on export. So the whole thing seems a bit
sketchy and inconsistent. Probably needs an audit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The structure contains local time and offset to UTC.

One might argue that it is best practice to use UTC when knowing
the offset to UTC. However, I don't want to change semantics
with respect to what we have always used.

For now, use the new structure in struct dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Note that this datum is not yet persisted or accessible from the UI.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The DiveTripModel expected dives to remain ordered when changing
the time. Currently, this is the case because bulk time changes
are by a delta.

To support more complex time operations, allow for reordering.
Thereto dives have to be sorted according to the position in
the model, not their time.

Yes, this is a fundamental flaw in how we handle the models:
Dives are modified in the backend and then signals are sent.
So if the dive-order changed, the model cannot assume that
its own representation matches the one of the backend.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This allows more complicated dive time changes, where not all dives
are shifted by the same amount.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Also, read it back in.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>