Skip to content

Commit

Permalink
- Fixed missing Open and Close tags for Statement
Browse files Browse the repository at this point in the history
- Fixed Date parsing in when time zone is missing. By default the timezone is UTC
  • Loading branch information
eramella committed Jan 20, 2019
1 parent 527ee51 commit 9f0672b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions QFXparser/QFXparser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ private RawStatement BuildRaw()
_currentTransaction = null;
break;
case NodeType.StatementProp:
if (_statement == null)
{
_statement = new RawStatement();
}
currentMember = result.Member;
break;
case NodeType.TransactionProp:
currentMember = result.Member;
break;
Expand Down
10 changes: 7 additions & 3 deletions QFXparser/RawTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ public DateTime DatePosted
var dateStr = PostedOn.Substring(0, 12) + "Z";
Regex regex = new Regex(@"(?<=\[)([^)]+)(?=\])");
var tzstr = regex.Match(PostedOn).Groups[0].Value;
var tzstrSplit = tzstr.Split(':');
var timeSpan = Convert.ToDouble(tzstrSplit[0]);
TimeZoneInfo tzi = TimeZoneInfo.Utc;
if (!string.IsNullOrEmpty(tzstr))
{
var tzstrSplit = tzstr.Split(':');
var timeSpan = Convert.ToDouble(tzstrSplit[0]);
tzi = TimeZoneInfo.CreateCustomTimeZone(tzstrSplit[1], TimeSpan.FromHours(timeSpan), tzstrSplit[1], tzstrSplit[1]);
}
var date = DateTimeOffset.ParseExact(dateStr, "yyyyMMddHHmmZ", CultureInfo.InvariantCulture);
var tzi = TimeZoneInfo.CreateCustomTimeZone(tzstrSplit[1], TimeSpan.FromHours(timeSpan), tzstrSplit[1], tzstrSplit[1]);
var newdate = TimeZoneInfo.ConvertTime(date, tzi);
return newdate.DateTime;
}
Expand Down

0 comments on commit 9f0672b

Please sign in to comment.