add dive implementation pushed
Dirk Hohndel
dirk at hohndel.org
Fri Sep 20 07:59:03 UTC 2013
On Fri, 2013-09-20 at 09:48 -0500, Thiago Macieira wrote:
> On sexta-feira, 20 de setembro de 2013 09:08:17, Dirk Hohndel wrote:
> > No - that doesn't work in the context of a divelog. Divecomputers
> > universally use localtime. Some claim to have TZ offsets (like the
> > Uemis), but that's just "FYI". All time stamps are always local time.
> >
> > So when we add or plan a dive, we need to be able to get the current
> > time in local time - expressed as seconds since Epoch. Here's what I
> > think would do it:
> >
> > diveplan.when = (t.msec() + QDateTime::currentMSecsSinceEpoch()) / 1000
> > - Qt::OffsetFromUTC * 3600;
> >
> > where t is the QTime widget used to enter the time offset from 'now'.
>
> Qt::OffsetFromUTC is just an enum to indicate type. Don't use it in math like
> that.
:-(
> I'm looking at the code for QDateTime::utcOffset() in Qt 4.8 and it looks
> broken. It won't give you the offset for a local-time QDateTime. So your
> googling was right...
>
> QDateTime works fine for local times, so when you download the dive computer
> data, or when you do planning, it should just work, provided of course, that
> you set your computer's timezone correctly.
Yes. But how can I get 'now' as a QDateTime that mixes nicely with these
localtime values?
/D
More information about the subsurface
mailing list