add dive implementation pushed

Thiago Macieira thiago at macieira.org
Fri Sep 20 07:48:02 UTC 2013


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.

But to convert that to universal + offset, you'd have to compare the date and 
times and do math. Same thing if you stick to gmtime and localtime.


-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130920/382be0ba/attachment.sig>


More information about the subsurface mailing list