109 message_out(
ERROR,
"ofxdate_to_time_t(): Unable to convert time, string is 0 length!");
112 string ofxdate_whole =
113 ofxdate.substr(0, ofxdate.find_first_not_of(
"0123456789"));
115 if (ofxdate_whole.size() < 8)
117 message_out(
ERROR,
"ofxdate_to_time_t(): Unable to convert time, string " + ofxdate +
" is not in proper YYYYMMDDHHMMSS.XXX[gmt offset:tz name] format!");
118 return std::time(NULL);
122 memset(&time, 0,
sizeof(tm));
123 time.tm_year = atoi(ofxdate_whole.substr(0, 4).c_str()) - 1900;
124 time.tm_mon = atoi(ofxdate_whole.substr(4, 2).c_str()) - 1;
125 time.tm_mday = atoi(ofxdate_whole.substr(6, 2).c_str());
127 if (ofxdate_whole.size() < 14)
129 message_out(
WARNING,
"ofxdate_to_time_t(): Successfully parsed date part, but unable to parse time part of string " + ofxdate_whole +
". It is not in proper YYYYMMDDHHMMSS.XXX[gmt offset:tz name] format!");
133 time.tm_hour = atoi(ofxdate_whole.substr(8, 2).c_str());
134 time.tm_min = atoi(ofxdate_whole.substr(10, 2).c_str());
135 time.tm_sec = atoi(ofxdate_whole.substr(12, 2).c_str());
138 if (time.tm_hour + time.tm_min + time.tm_sec == 0)
143 return timegm(&time);
146 string::size_type startidx = ofxdate.find(
"[");
147 if (startidx != string::npos)
150 string::size_type endidx = ofxdate.find(
":", startidx) - 1;
151 string offset_str = ofxdate.substr(startidx, (endidx - startidx) + 1);
152 float ofx_gmt_offset = atof(offset_str.c_str());
153 std::time_t temptime = std::time(
nullptr);
154 static const double secs_per_hour = 3600.0;
155 time.tm_sec -=
static_cast<int>(ofx_gmt_offset * secs_per_hour);
156 return timegm(&time);
160 return timegm(&time);
194 string temp_string = para_string;
195 if (temp_string.empty())
198 const char *whitespace =
" \b\f\n\r\t\v";
199 const char *abnormal_whitespace =
"\b\f\n\r\t\v";
203 i <= temp_string.size()
204 && temp_string.find_first_of(whitespace, i) == i
205 && temp_string.find_first_of(whitespace, i) != string::npos;
207 temp_string.erase(0, i);
209 for (i = temp_string.size() - 1;
211 && (temp_string.find_last_of(whitespace, i) == i)
212 && (temp_string.find_last_of(whitespace, i) != string::npos);
214 temp_string.erase(i + 1, temp_string.size() - (i + 1));
216 while ((index = temp_string.find_first_of(abnormal_whitespace)) != string::npos)
218 temp_string.erase(index, 1);