1 const float Pi = 3.141593;
15 tm_date = localtime(&t);
16 tm_date->tm_year += floor(monthNbr / 12);
17 monthNbr = monthNbr % 12;
20 if (tm_date->tm_mon == 11)
44 x = difftime(mktime(&tmDate),now);
53 return (to_string(tmDate.tm_year + 1900) +
"-" + to_string(tmDate.tm_mon + 1) +
"-" + to_string(tmDate.tm_mday)); }
64 memset(xDate, 0,
sizeof(
struct tm));
65 strptime(dStr.c_str(),
"%Y-%m-%d", xDate);
88 tm_date =
get_tm(monthNbr);
100 if (!strptime(theDate.c_str(),
"%Y-%m-%d", &tmDate)) rc =
false;
107 inline float flSum(std::map<int, float>* theMap,
int N) {
110 for (k = 0; k <= N; k++) {theSum += (*theMap)[k];}
120 int j , i = 0, k = 0, ix = (x >= 0 )?(
int)floor(x):(int)ceil(x);
141 s[k] = char ((ix/p) +
'0');
147 if ((k % 3 == 0 && i > 0)||(j == 0 && i > 2) )
173 sprintf(s,
"%.02f", x);
174 if (theCurr ==
"EUR") strcat(s,
" €");
175 else strcat(s,theCurr.c_str());
193 const string radix =
".";
194 const string thousands =
",";
195 string the_sign, unit;
196 if (the_curr ==
"EUR") unit =
" €";
197 else if (the_curr ==
"USD") unit =
" $";
198 else if (the_curr ==
"GBP") unit =
" £";
199 else if (the_curr ==
"JPY") unit =
" ¥";
200 else unit = the_curr;
210 unsigned long v = (
unsigned long) ((dv * 100.0) + .5);
217 if((i > 0) && (!(i % 3))) {
218 fmt = thousands + fmt;
220 digit = (v % 10) +
'0';
225 while((v) || (i < 1));
227 return unit + the_sign + fmt;
238 return to_string(the_tm->tm_year + 1900) +
"-" + to_string(the_tm->tm_mon + 1) +
"-" + to_string(the_tm->tm_mday);
250 return to_string(the_tm.tm_year + 1900) +
"-" + to_string(the_tm.tm_mon + 1) +
"-" + to_string(the_tm.tm_mday);
261 if (x < 0) s =
"-" + s;
265 s = s + to_string((
int) x);
266 int x_dec = round((x - (
int)x) * pow(10, nbr_digits));
267 s = s +
"." + to_string(x_dec);
271 s = s + to_string((
int)(x + 0.5));
285 int yrs = (int)(m /12);
286 if (yrs >= 2) s = to_string(yrs) +
" " +
t_years;
287 else if (yrs >= 1) s = to_string(yrs) +
" " +
t_year;
292 if ((yrs != 0) && (m > 1)) s = s +
" " +
t_and +
" ";
294 if (m >= 2) s = s + to_string(m) +
" " +
t_months;
295 else if (m >= 1) s = s + to_string(m) +
" " +
t_month;
297 if ((yrs == 0) && (m == 0)) s =
"0 " +
t_months;
311 inline string add0(
int x,
int n = 1)
315 for (digits = 1; digits <= n; digits++)
317 if (x < pow(10,digits)) s = s +
"0";
319 s = s + to_string(x);
string currFormat(float x, string theCurr)
const string t_month
General words.
string round2str(float x, int nbr_digits=0)
bool is_valid_dateStr(string theDate)
string date_format_dateStr(string s)
const float Pi
global variables
string add0(int x, int n=1)
tm get_tm(int monthNbr=0)
global functions
void thousand_separator(float x, char *s)
string curr_format(float dv, string the_curr="")
string tm2DateStr(tm tmDate)
string date_format_tm(tm *the_tm)
int dateStr2Mnbr(string dStr)
void dateStr2tm(string dStr, tm *target_tm)
#define SECONDS_IN_MONTH
Marco's:
float flSum(std::map< int, float > *theMap, int N)
string mNbr2dateStr(int monthNbr=0)