Subject: | Datetime fields in OFX file do not always get correct timezone adjustment [PATCH] |
Date: | Tue, 09 Mar 2010 20:34:05 -0800 |
To: | bug-p5-Finance-OFX [...] rt.cpan.org |
From: | Brad Rubenstein <Brad [...] BradRubenstein.com> |
Hi - I am finding the Finance::OFX::Parse package extremely useful.
Thank you for writing it. I hope you find this minor fix appropriate.
Finance::OFX::Parse is interpreting time-zoneless datetimes as if they
were in the local time zone (the time zone of the process doing the
parsing).
I believe they should be interpreted by the parser as GMT times to match
the OFX spec (and so I don't get different transaction dates when I
parse the file in different locations). For reference, the OFX spec
(here <http://www.ofx.net/DownloadPage/Downloads.aspx>) section 3.2.8.2
says that datetime fields that are missing a time zone are valid, and
are to be interpreted as GMT.
I notice that HTTP::Date::str2time is used by the parse routine, and
str2time uses the local time zone when the time parameter contains no
zone, and no default zone is given. So I just set the default timezone
to "GMT", and it works for me.
My Patch:
*** Parse.pm.orig 2008-03-03 20:19:18.000000000 -0800
--- Parse.pm 2010-03-09 20:10:46.458164816 -0800
***************
*** 85,91 ****
# Handle timezone offsets that were already 2 digits
$tree->{$_} =~ s/\[([-+]?)([0-9]{1,2}):[A-Z]{3}\]/ $1$2\x30\x30/;
# Do the conversion
! $tree->{$_} = str2time($tree->{$_});
}
else
{
--- 85,91 ----
# Handle timezone offsets that were already 2 digits
$tree->{$_} =~ s/\[([-+]?)([0-9]{1,2}):[A-Z]{3}\]/ $1$2\x30\x30/;
# Do the conversion
! $tree->{$_} = str2time($tree->{$_}, "GMT");
}
else
{