/* HomeBank -- Free, easy, personal accounting for everyone.
- * Copyright (C) 1995-2016 Maxime DOYEN
+ * Copyright (C) 1995-2018 Maxime DOYEN
*
* This file is part of HomeBank.
*
gdouble hb_amount_to_euro(gdouble amount)
{
- return hb_amount_round((amount / PREFS->euro_value), 2);
- //return hb_amount_round((amount * PREFS->euro_value), PREFS.minor_cur->frac_digits);
+ return hb_amount_round((amount * PREFS->euro_value), PREFS->minor_cur.frac_digits);
}
}
else
{
+ monval = hb_amount_base(value, kcur);
+ monval = hb_amount_to_euro(monval);
cur = &PREFS->minor_cur;
- monval = hb_amount_to_euro(value);
g_ascii_formatd(formatd_buf, outlen, cur->format, monval);
hb_str_formatd(outstr, outlen, formatd_buf, cur, TRUE);
}
}
+
void hb_strfmon_int(gchar *outstr, gint outlen, gdouble value, guint32 kcur, gboolean minor)
{
gchar formatd_buf[outlen];
}
else
{
+ monval = hb_amount_base(value, kcur);
+ monval = hb_amount_to_euro(monval);
cur = &PREFS->minor_cur;
- monval = hb_amount_to_euro(value);
g_ascii_formatd(formatd_buf, outlen, cur->format, monval);
hb_str_formatd(outstr, outlen, formatd_buf, cur, TRUE);
}
if(cur != NULL)
{
monval = hb_amount_round(value, cur->frac_digits);
- g_ascii_formatd(formatd_buf, outlen, "%0.f", monval);
+ g_ascii_formatd(formatd_buf, outlen, "%.2f", monval);
hb_str_formatd(outstr, outlen, formatd_buf, cur, TRUE);
}
}
{
cur = &PREFS->minor_cur;
monval = hb_amount_to_euro(value);
- g_ascii_formatd(formatd_buf, outlen, "%0.f", monval);
+ g_ascii_formatd(formatd_buf, outlen, "%.2f", monval);
hb_str_formatd(outstr, outlen, formatd_buf, cur, TRUE);
}
}
-
gchar *get_normal_color_amount(gdouble value)
{
gchar *color = NULL;
}
-/*static void strip_extra_spaces(char* str) {
+gchar *hb_string_copy_jsonpair(gchar *dst, gchar *str)
+{
+
+ while( *str!='\0' )
+ {
+ if( *str=='}' )
+ break;
+
+ if( *str==',' )
+ {
+ *dst = '\0';
+ return str + 1;
+ }
+
+ if( *str!='{' && *str!='\"' )
+ {
+ *dst++ = *str;
+ }
+ str++;
+ }
+ *dst = '\0';
+ return NULL;
+}
+
+
+void hb_string_inline(gchar *str)
+{
+gchar *s = str;
+gchar *d = str;
+
+ if(str)
+ {
+ while( *s )
+ {
+ if( !(*s==' ' || *s=='\t' || *s=='\n' || *s=='\r') )
+ {
+ *d++ = *s;
+ }
+ s++;
+ }
+ *d = 0;
+ }
+}
+
+
+/*void strip_extra_spaces(char* str) {
int i,x;
for(i=x=1; str[i]; ++i)
if(!isspace(str[i]) || (i>0 && !isspace(str[i-1])))
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =*/
-gchar *hb_util_filename_new_with_extension(gchar *filename, const gchar *extension)
+gchar *hb_filename_new_with_extension(gchar *filename, const gchar *extension)
{
gchar *lastdot, *fwe;
gchar *newfilename;
g_date_get_month(&date),
g_date_get_year(&date)
);
- }
+ }
+ break;
default:
g_sprintf(outstr, "%04d/%02d/%02d",
g_date_get_year(&date),