[PATCH] Fix DM4 dive time

Miika Turkia miika.turkia at gmail.com
Wed May 15 00:22:39 PDT 2013


It should be DiveId as DM4 sees it. My own, Rainer's and Amit's DM4 logs
that I have received have this number as one would expect, increasing as
the dive date/time increases (there might be some dives missing from the
numbering, but in general it looks correct).

miika


On Wed, May 15, 2013 at 8:56 AM, Dirk Hohndel <dirk at hohndel.org> wrote:

>
> At least with the DM4 file that I have this creates the correct
> timestamps. The dive numbers appear to be completely insane, though...
>
> Are you sure that data[0] really is the dive number?
>
> I get (in default reverse chronological order)
>
> 148
> 144
> 13
> 145
> 7
> 24
> 6
> ...
>
> /D
>
> On Wed, 2013-05-15 at 08:07 +0300, Miika Turkia wrote:
> > DM4 stores the divetime in local time. The conversion from seconds since
> > year 1 was 2 hours off. (So there is no timezones involved, which is
> > good for us!)
> >
> > Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
> > ---
> >  parse-xml.c |   14 ++------------
> >  1 file changed, 2 insertions(+), 12 deletions(-)
> >
> > diff --git a/parse-xml.c b/parse-xml.c
> > index d6c189c..698b311 100644
> > --- a/parse-xml.c
> > +++ b/parse-xml.c
> > @@ -1690,8 +1690,6 @@ extern int dm4_dive(void *param, int columns, char
> **data, char **column)
> >       float *profileBlob;
> >       unsigned char *tempBlob;
> >       int *pressureBlob;
> > -     time_t when;
> > -     struct tm *tm;
> >       char *err = NULL;
> >       char get_events_template[] = "select * from Mark where DiveId =
> %d";
> >       char get_events[64];
> > @@ -1699,15 +1697,7 @@ extern int dm4_dive(void *param, int columns,
> char **data, char **column)
> >       dive_start();
> >       cur_dive->number = atoi(data[0]);
> >
> > -     when = (time_t)(atol(data[1]));
> > -     tm = localtime(&when);
> > -
> > -     /* Bailing out if localtime returns NULL */
> > -     if (!tm)
> > -             return -1;
> > -
> > -     /* Timezones are not taken into account */
> > -     cur_dive->when = mktime(tm);
> > +     cur_dive->when = (time_t)(atol(data[1]));
> >       if (data[2])
> >               utf8_string(data[2], &cur_dive->notes);
> >
> > @@ -1821,7 +1811,7 @@ int parse_dm4_buffer(const char *url, const char
> *buffer, int size,
> >
> >       /* StartTime is converted from Suunto's nano seconds to standard
> >        * time. We also need epoch, not seconds since year 1. */
> > -     char get_dives[] = "select
> D.DiveId,StartTime/10000000-62135604000,Note,Duration,SourceSerialNumber,Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,Size,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium,MIX.StartPressure,MIX.EndPressure
> FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId";
> > +     char get_dives[] = "select
> D.DiveId,StartTime/10000000-62135596800,Note,Duration,SourceSerialNumber,Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,Size,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium,MIX.StartPressure,MIX.EndPressure
> FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId";
> >
> >       retval = sqlite3_open(url,&handle);
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130515/62707085/attachment-0001.html>


More information about the subsurface mailing list