GnuCash c935c2f+
Loading...
Searching...
No Matches
dialog-bi-import-helper.c
1
22#ifdef HAVE_CONFIG_H
23#include <config.h>
24#endif
25
26#include "dialog-bi-import-helper.h"
27#include <ctype.h>
28#include <time.h>
29#ifndef HAVE_STRPTIME
30#include <strptime.h>
31#endif
32
34gboolean text2bool( const gchar *text )
35{
36 gboolean erg = FALSE;
37 gchar *temp;
38
39 if (!text)
40 return erg;
41
42 temp = g_strdup( text );
43 g_strstrip( temp );
44 if ((g_ascii_strncasecmp( temp, "y",1 ) == 0) || (g_ascii_strncasecmp( temp, "t",1 ) == 0) ||
45 (g_ascii_strcasecmp( temp, "1" ) == 0) || (g_ascii_strcasecmp( temp, "x" ) == 0))
46 erg = TRUE;
47 g_free( temp );
48 return erg;
49}
50
51
53// Try to make a valid tm using the user set date format. Return false if it fails.
54gboolean
55isDateValid(char * date_string)
56{
57 char *tmp;
58 const gchar* date_format_string = qof_date_format_get_string (qof_date_format_get()); // Get the user set date format string
59
60 struct tm time_struct;
61 memset(&time_struct, 0, sizeof(struct tm));
62
63 tmp = strptime(date_string, date_format_string, &time_struct);
64 if (tmp == NULL) return FALSE;
65 return TRUE;
66}
67
69GncAmountType text2disc_type( const gchar *text )
70{
72 gchar *temp;
73
74 if (!text)
75 return type;
76
77 temp = g_strdup( text );
78 g_strstrip( temp );
79 if ((strlen(temp) > 0) && (g_ascii_strcasecmp( temp, "%" ) != 0))
80 type = GNC_AMT_TYPE_VALUE;
81 g_free( temp );
82 return type;
83}
84
86GncDiscountHow text2disc_how( const gchar *text )
87{
88 GncDiscountHow how = GNC_DISC_PRETAX;
89 gchar *temp;
90
91 if (!text)
92 return how;
93
94 temp = g_strdup( text );
95 g_strstrip( temp );
96 if (g_ascii_strcasecmp( temp, "=" ) == 0)
97 how = GNC_DISC_SAMETIME;
98 else if (g_ascii_strcasecmp( temp, ">" ) == 0)
99 how = GNC_DISC_POSTTAX;
100 g_free( temp );
101 return how;
102}
QofDateFormat qof_date_format_get(void)
The qof_date_format_get routine returns the date format that the date printing will use when printing...
Definition gnc-date.cpp:428
const gchar * qof_date_format_get_string(QofDateFormat df)
This function returns a strftime formatting string for printing an all numeric date (e....
Definition gnc-date.cpp:502
GncAmountType
How to interpret the amount.
Definition gncTaxTable.h:79
@ GNC_AMT_TYPE_VALUE
tax is a number
Definition gncTaxTable.h:80
@ GNC_AMT_TYPE_PERCENT
tax is a percentage
Definition gncTaxTable.h:81