Main Page | Class Hierarchy | Data Structures | File List | Data Fields | Globals

ofx_utilities.cpp File Reference


Detailed Description

Various simple functions for type conversion & al.

Definition in file ofx_utilities.cpp.

Go to the source code of this file.

Functions

string CharStringtostring (const SGMLApplication::CharString source, string &dest)
 Convert OpenSP CharString to a C++ STL string.

string AppendCharStringtostring (const SGMLApplication::CharString source, string &dest)
 Append an OpenSP CharString to an existing C++ STL string.

time_t ofxdate_to_time_t (const string ofxdate)
 Convert a C++ string containing a time in OFX format to a C time_t.

double ofxamount_to_double (const string ofxamount)
 Convert OFX amount of money to double float.

string strip_whitespace (const string para_string)
 Sanitize a string coming from OpenSP.


Function Documentation

string CharStringtostring const SGMLApplication::CharString  source,
string &  dest
 

Convert OpenSP CharString to a C++ STL string.

Convert an OpenSP CharString directly to a C++ stream, to enable the use of cout directly for debugging.

Definition at line 60 of file ofx_utilities.cpp.

double ofxamount_to_double const string  ofxamount  ) 
 

Convert OFX amount of money to double float.

Convert a C++ string containing an amount of money as specified by the OFX standard and convert it to a double float.

Note:
The ofx number format is the following: "." or "," as decimal separator, NO thousands separator.

Definition at line 165 of file ofx_utilities.cpp.

time_t ofxdate_to_time_t const string  ofxdate  ) 
 

Convert a C++ string containing a time in OFX format to a C time_t.

Converts a date from the YYYYMMDDHHMMSS.XXX[gmt offset:tz name] OFX format (see OFX 2.01 spec p.66) to a C time_t.

Parameters:
ofxdate date from the YYYYMMDDHHMMSS.XXX[gmt offset:tz name] OFX format
Returns:
C time_t in the local time zone
Note:
  • The library always returns the time in the systems local time
  • OFX defines the date up to the millisecond. The library ignores those milliseconds, since ANSI C does not handle such precision cleanly. The date provided by LibOFX is precise to the second, assuming that information this precise was provided in the ofx file. So you wont know the millisecond you were ruined...

DEVIATION FROM THE SPECS : The OFX specifications (both version 1.6 and 2.02) state that a client should assume that if the server returns a date without à specific time, we assume it means 0h00 GMT. As such, when we apply the local timezone and for example you are in the EST timezone, we will remove 5h, and the transaction will have occurred on the prior day! This is probably not what the bank intended (and will lead to systematic errors), but the spec is quite explicit in this respect (Ref: OFX 2.01 spec pp. 66-68)

To solve this problem (since usually a time error is relatively unimportant, but date error is), and to avoid problems in Australia caused by the behaviour in libofx up to 0.6.4, it was decided starting with 0.6.5 to use the following behavior:

-No specific time is given in the file (date only): Considering that most banks seem to be sending dates in this format represented as local time (not compliant with the specs), the transaction is assumed to have occurred 11h59 (just before noon) LOCAL TIME. This way, we should never change the date, since you'd have to travel in a timezone at least 11 hours backwards or 13 hours forward from your own to introduce mistakes. However, if you are in timezone +13 or +14, and your bank meant the data to be interpreted by the spec, you will get the wrong date. We hope that banks in those timezone will either represent in local time like most, or specify the timezone properly.

-No timezone is specified, but exact time is, the same behavior is mostly used, as many banks just append zeros instead of using the short notation. However, the time specified is used, even if 0 (midnight).

-When a timezone is specified, it is always used to properly convert in local time, following the spec.

Definition at line 97 of file ofx_utilities.cpp.

string strip_whitespace const string  para_string  ) 
 

Sanitize a string coming from OpenSP.

Many weird caracters can be present inside a SGML element, as a result on the transfer protocol, or for any reason. This function greatly enhances the reliability of the library by zapping those gremlins (backspace,formfeed,newline,carriage return, horizontal and vertical tabs) as well as removing whitespace at the begining and end of the string. Otherwise, many problems will occur during stringmatching.

Definition at line 186 of file ofx_utilities.cpp.


Generated on Fri Sep 12 00:35:47 2003 for LibOFX by doxygen 1.3.3