OFX Import Bug

Brendan Coupe brendan at coupeware.com
Tue Jan 17 03:27:09 UTC 2017


Thomas,

We've had this conversation many years ago. I think you said you spent some
time in Santa Monica. I was living in Redondo beach at the time. I live in
Palos Verdes now (still the LA area).

Have you thought about how best to deal with the two cases that I've run
into?

I took a quick look at the libofx code that you modified so many years ago.
Further down in the code (copied below) it checks if the time zone is
specified and if it's not it is supposed to assume 11:59:00 local time.

In the two cases that I've run into the time zone is not specified in the
DTEND field so I would expect the time to be set to 11:59:00 local time and
it should work. In one case DTEND is not specified so I'm not sure it gets
this far but in the other it does not appear to be specified. I did see
other ofx files with the DTEND time zone specified so I'm wondering why
this is not working.

It appears that time_zone_specified is being set improperly. I'm not sure
why since there is not a "[" in the DTEND value in the ofx file that seems
to be adjusting to the previous day.

I have no idea how to figure out what libofx does when DTEND is missing.
I'd guess nothing and that KMM had to deal with getting nothing back. Could
KMM handle getting a zero or null for DTEND better?

=======================================
 /* Check if the timezone has been specified */
    string::size_type startidx = ofxdate.find("[");
    string::size_type endidx;
if (startidx != string::npos)
    {
      /* Time zone was specified */
      time_zone_specified = true;
      startidx++;
      endidx = ofxdate.find(":", startidx) - 1;
      ofx_gmt_offset = atof(ofxdate.substr(startidx, (endidx - startidx) +
1).c_str());
      startidx = endidx + 2;
      strncpy(timezone, ofxdate.substr(startidx, 3).c_str(), 4);
    }
    else
    {
      /* Time zone was not specified, assume GMT (provisionnaly) in case
exact time is specified */
      ofx_gmt_offset = 0;
      strcpy(timezone, "GMT");
    }

if (time_zone_specified == true)
    {
      /* If the timezone is specified always correct the timezone */
      /* If the timezone is not specified, but the exact time is, correct
the timezone, assuming GMT following the spec */
      /* Correct the time for the timezone */
      time.tm_sec = time.tm_sec + (int)(local_offset - (ofx_gmt_offset * 60
* 60)); //Convert from fractionnal hours to seconds
    }
    else if (exact_time_specified == false)
    {
      /*Time zone data missing and exact time not specified, diverge from
the OFX spec ans assume 11h59 local time */
      time.tm_hour = 11;
      time.tm_min = 59;
      time.tm_sec = 0;
    }
    return mktime(&time);



*----Brendan*

On Fri, Jan 13, 2017 at 6:46 AM, jeffjl at outlook.com <jeffjl.kde at outlook.com>
wrote:

>
> On 1/13/2017 3:36 AM, Thomas Baumgart wrote:
>
> Thanks for the detailed analysis. I think it hits the nail right on the
> head.
>
> Date and timezone handling is all done by libOFX (I fixed something myself in
> that are sometime ago - wow 7 years: https://github.com/libofx/libofx/commit/166b97964de3ed3986346f8844d8029ca11e3d79,
> the internet does not forget)
>
> Not sure what we can do about it since all that is handled by libOFX AFAIR.
>
> I had the same exact problem with libOFX on Windows. A time of midnight
> was getting converted to 11:00 PM the previous day when daylight savings
> time was not in effect. I fixed it in my local build of libOFX by changing
> line 118 of Thomas' patch to
>
> time.tm_isdst = -1; //mktime() will figure out daylight savings based on
> locale
>
> For me, this works both when DST is in effect and when it is not.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20170116/d6a9a8b0/attachment.html>


More information about the KMyMoney-devel mailing list