webservice dive matching?

Linus Torvalds torvalds at linux-foundation.org
Tue May 21 10:37:08 PDT 2013


On Tue, May 21, 2013 at 10:06 AM, Aurélien PRALONG
<aurelien.pralong at gmail.com> wrote:
> You misunderstand the problem. The companion never created doubles. It's
> when synchronising with the server that doubles appear, because the
> companion doesn't save date sent as string, but an utc timestamp,

THE EXACT FACT THAT YOU ARE USING UTC TIMESTAMP IS THE BUG.

DON'T DO THAT. It's f*cking moronic.

So your explanation for this bug is "I use UTC timestamps because I
use UTC timestamps". Don't you see how stupid an explanation that is?

STOP USING UTC.

Seriously. It's that simple. There is no correct way to use UTC. Ever.
Stop doing it. There is *never* a good reason to do it.

There are exactly three valid ways of showing time:

 - localtime string (possibly with explicit timezone data).

 - localtime encoded in a "time_t":AS IF IT WAS UTC.

   So it's 12:05 in Hawaii, but you encode that as the number that is
equivalent to 12:05 UTC:

        time_t now = time(NULL);
        struct tm *local = localtime(&now);
        return utc_mktime(local);

   This is what subsurface itself uses.

 - time_t UTC with explicit timezone data IN MINUTES (not string) that
you cannot possibly lose.

   This is what git uses.

And quite frankly, the last one is not relevant for subsurface or the
companion app, for the simple reason that we usually don't *have* the
timezone.

So you have exactly two cases left. If you're not using either of
those two cases, you're fundamentally buggy. Don't make excuses.

Your "duplicate dives" is exactly because you are confused about
whether dates are localtime or UTC, and then sometimes you use one,
and sometimes the other. It's a bug. It's fundamental. Don't do it.

                  Linus


More information about the subsurface mailing list