[PATCH] Attempt to fix a crash on DM4 Windows import

Miika Turkia miika.turkia at gmail.com
Thu May 9 10:40:03 PDT 2013


On Thu, May 9, 2013 at 7:29 PM, Lubomir I. Ivanov <neolit123 at gmail.com>wrote:

> On 9 May 2013 18:09, Dirk Hohndel <dirk at hohndel.org> wrote:
> > On Thu, 2013-05-09 at 09:50 +0300, Miika Turkia wrote:
> >> It appears that Windows returns NULL when converting DM4 database's date
> >> stamps to local time. (This is due to DM4 using time since year 1, not
> >> epoch and Windows doing "sanity checking" on the time.)
> >>
> >> This patch moves the conversion of time format directly to database
> >> query so the localtime should function on Windows. It will also fail
> >> gracefully in case of NULL (with error message: failed to parse input).
> >>
> >> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
> >> ---
> >> +     /*
> >> +      * I am not sure about the timezones when it comes to Suunto
> >> +      * DM4. However, with a sample on GMT+2 and another in GMT+1
> >> +      * this code seems to work.
> >> +      * Remaining question is, how to handle daylight savings.
> >> +      * (Samples I have are contradicting each other...)
> >> +      */
> >> +     tm->tm_hour += tm->tm_gmtoff / 3600;
> >> +     tm->tm_min += tm->tm_gmtoff % 3600;
> >
> > tm_gmtoff is an extension that I believe does not exist on Windows...
> >
>
> http://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html
> "The tm_gmtoff field is derived from BSD and is a GNU library
> extension; it is not visible in a strict ISO C environment. "
> yes, it's not available...not that Windows is a "strict ISO C environment."
>
> i think this should give a similar result:
> time_t raw = time(NULL);
> time_t tm_gmtoff = mktime(localtime(&raw)) - mktime(gmtime(&raw));
>
> lubomir
> --
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130509/5076a408/attachment.html>


More information about the subsurface mailing list