gboolean csv_import_parse_date ( struct struct_ope_importation * ope, gchar * string ) { g_return_val_if_fail ( string, FALSE ); if ( ope -> date ) g_date_free ( ope-> date ); ope -> date = gsb_parse_date_string ( string ); if ( ! ope -> date ) { ope -> date = gdate_today (); } return g_date_valid ( ope -> date ); }
/** * called for add a new financial year * * \param tree_view * * \return FALSE * */ gboolean gsb_fyear_config_add_fyear ( GtkWidget *tree_view ) { GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *selection; GtkWidget *entry; gint fyear_number; GDate *date; fyear_number = gsb_data_fyear_new (_("New financial year")); /* if bad things will append soon ... */ if (!fyear_number) return FALSE; gsb_data_fyear_set_form_show ( fyear_number, TRUE ); gsb_data_fyear_set_beginning_date ( fyear_number, date = gdate_today()); gsb_data_fyear_set_end_date ( fyear_number, date ); g_date_free (date); model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); /* append to the list and get back the iter */ gsb_fyear_config_append_line ( model, fyear_number, &iter ); /* select it */ gtk_tree_selection_select_iter ( GTK_TREE_SELECTION (selection), &iter ); /* select the new name and give it the focus */ entry = g_object_get_data ( G_OBJECT (model), "fyear_name_entry"); gtk_editable_select_region ( GTK_EDITABLE (entry), 0, -1 ); gtk_widget_grab_focus (entry); /* Update various menus */ gsb_fyear_update_fyear_list (); gsb_file_set_modified ( TRUE ); return FALSE; }
/** * start the reconciliation, called by a click on the * reconcile button * * \param button the button we click to come here * \param null not used * * \return FALSE * */ gboolean gsb_reconcile_run_reconciliation ( GtkWidget *button, gpointer null ) { GDate *date; gint account_number; gint reconcile_number; gchar *label; gchar *string; gchar* tmpstr; account_number = gsb_gui_navigation_get_current_account (); reconcile_number = gsb_data_reconcile_get_account_last_number (account_number); label = gsb_reconcile_build_label ( reconcile_number ); gtk_entry_set_text ( GTK_ENTRY ( reconcile_number_entry ), label ); g_free ( label ); /* reset records in run structure if user has changed of account */ if (run.reconcile_account_number != account_number) { g_free (run.reconcile_final_balance); if (run.reconcile_new_date) g_date_free (run.reconcile_new_date); run.reconcile_final_balance = NULL; run.reconcile_new_date = NULL; run.reconcile_account_number = -1; } /* set last input date/amount if available */ if (run.reconcile_new_date) { date = run.reconcile_new_date; } else { /* increase the last date of 1 month */ date = gsb_date_copy (gsb_data_reconcile_get_final_date (reconcile_number)); if (date) { GDate *today; gchar *string ; string = gsb_format_gdate ( date ); gtk_label_set_text ( GTK_LABEL ( reconcile_last_date_label ), string); gtk_widget_set_sensitive ( GTK_WIDGET ( reconcile_last_date_label ), FALSE ); g_free (string); g_date_add_months ( date, 1 ); /* if etat.reconcile_end_date or the new date is after today, set today */ today = gdate_today(); if ( etat.reconcile_end_date || g_date_compare ( date, today) > 0 ) { g_date_free (date); date = gdate_today(); } else g_date_free (today); /* it's not the first reconciliation, set the old balance and unsensitive the old balance entry */ tmpstr = utils_real_get_string (gsb_data_reconcile_get_final_balance (reconcile_number)); gtk_entry_set_text ( GTK_ENTRY ( reconcile_initial_balance_entry ), tmpstr); g_free ( tmpstr ); gtk_widget_set_sensitive ( GTK_WIDGET ( reconcile_initial_balance_entry ), FALSE ); } else { gtk_label_set_text ( GTK_LABEL ( reconcile_last_date_label ), _("None") ); date = gdate_today(); /* it's the first reconciliation, set the initial balance and make sensitive the old balance to change * it if necessary */ tmpstr = utils_real_get_string ( gsb_data_account_get_init_balance (account_number, -1)); gtk_entry_set_text ( GTK_ENTRY ( reconcile_initial_balance_entry ), tmpstr); g_free ( tmpstr ); gtk_widget_set_sensitive ( GTK_WIDGET ( reconcile_initial_balance_entry ), TRUE ); } } string = gsb_format_gdate (date); gtk_entry_set_text ( GTK_ENTRY ( reconcile_new_date_entry ), string ); g_free (string); g_date_free (date); /* set last input amount if available and if the account is the good one */ gtk_entry_set_text ( GTK_ENTRY ( reconcile_final_balance_entry ), (run.reconcile_final_balance) ? run.reconcile_final_balance : ""); g_free(run.reconcile_final_balance); /* set the title */ tmpstr = g_markup_printf_escaped ( _(" <b>%s reconciliation</b> "), gsb_data_account_get_name (account_number)); gtk_label_set_markup ( GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (reconcile_panel))), tmpstr ); g_free ( tmpstr ); /* we go to the reconciliation mode */ run.equilibrage = 1; /* set all the balances for reconciliation */ gsb_reconcile_update_amounts (NULL, NULL); /* set the transactions list to reconciliation mode */ /* only change the current account */ reconcile_save_account_display = etat.retient_affichage_par_compte; etat.retient_affichage_par_compte = 1; /* hide the marked R transactions */ reconcile_save_show_marked = gsb_data_account_get_r (account_number); if (reconcile_save_show_marked) { gsb_data_account_set_r (account_number, FALSE ); mise_a_jour_affichage_r (FALSE); } /* 1 line on the transaction list */ reconcile_save_rows_number = gsb_data_account_get_nb_rows (account_number); if (reconcile_save_rows_number != 1) gsb_transactions_list_set_visible_rows_number ( 1 ); /* sort by method of payment if in conf */ if (gsb_data_account_get_reconcile_sort_type (account_number)) gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (reconcile_sort_list_button), TRUE ); gtk_widget_show_all ( reconcile_panel ); transaction_list_show_toggle_mark (TRUE); /* unsensitive all that could change the account number */ gsb_reconcile_sensitive (FALSE); gtk_widget_grab_focus ( GTK_WIDGET ( reconcile_number_entry ) ); return FALSE; }
/** * Actually do the grunt work, that is, parse the CSV file and create * importation structures in memory. * * \param assistant The assistant that contains configuration for * import. * \param imported A pointer to the structure representing file * import. * * \return FALSE */ gboolean csv_import_csv_account ( GtkWidget * assistant, struct imported_file * imported ) { struct struct_compte_importation * compte; gchar * contents, * separator; GSList * list; int index = 0; compte = g_malloc0 ( sizeof ( struct struct_compte_importation )); compte -> nom_de_compte = unique_imported_name ( my_strdup ( _("Imported CSV account" ) ) ); compte -> origine = my_strdup ( "CSV" ); compte -> filename = my_strdup ( imported -> name ); contents = g_object_get_data ( G_OBJECT(assistant), "contents" ); separator = g_object_get_data ( G_OBJECT(assistant), "separator" ); if ( ! csv_fields_config || ! contents ) { liste_comptes_importes_error = g_slist_append ( liste_comptes_importes_error, compte ); return FALSE; } list = csv_get_next_line ( &contents, separator ); do { struct struct_ope_importation * ope; gint i; /* Check if this line was specified as to be skipped * earlier. */ if ( index < CSV_MAX_TOP_LINES && etat.csv_skipped_lines [ index ] ) { /* g_print ("Skipping line %d\n", index ); */ list = csv_get_next_line ( &contents, separator ); index++; continue; } index++; ope = g_malloc0 ( sizeof ( struct struct_ope_importation ) ); ope -> date = gdate_today (); ope -> date_tmp = my_strdup ( "" ); ope -> tiers = my_strdup ( "" ); ope -> notes = my_strdup ( "" ); ope -> categ = my_strdup ( "" ); ope -> guid = my_strdup ( "" ); for ( i = 0; csv_fields_config[i] != -1 && list ; i++) { struct csv_field * field = & csv_fields [ csv_fields_config[i] ]; if ( field -> parse ) { if ( field -> validate ) { if ( field -> validate ( list -> data ) ) { if ( csv_fields_config[i] == 16 ) { if ( field -> parse ( ope, list -> data ) ) { gint nbre_element = g_slist_length ( compte -> operations_importees ); struct struct_ope_importation *ope_tmp; ope_tmp = (struct struct_ope_importation *) g_slist_nth_data ( compte -> operations_importees, nbre_element -1 ); if ( ope_tmp -> operation_ventilee == 0 && ope_tmp -> ope_de_ventilation == 0 ) ope_tmp -> operation_ventilee = 1; ope -> ope_de_ventilation = 1; } } else if ( ! field -> parse ( ope, list -> data ) ) { /* g_print ("%s", "(failed)"); */ } } else { /* g_print ("%s", "(invalid)"); */ } } } list = list -> next; } /* g_print (">> Appending new transaction %p\n", ope ); */ compte -> operations_importees = g_slist_append ( compte -> operations_importees, ope ); list = csv_get_next_line ( &contents, separator ); } while ( list ); if ( compte -> operations_importees ) { /* Finally, we register it. */ liste_comptes_importes = g_slist_append ( liste_comptes_importes, compte ); } else { /* ... or not, if no transaction was imported (implement sanitizing). */ liste_comptes_importes_error = g_slist_append ( liste_comptes_importes_error, compte ); } return FALSE; }
/** * called when something change for a link * * \param tree_view the tree_view * * \return FALSE * */ gboolean gsb_currency_link_config_modify_link ( GtkWidget *tree_view ) { GtkWidget *combobox_1; GtkWidget *combobox_2; GtkWidget *exchange_entry; GtkTreeModel *model; GtkTreeIter iter; gint link_number; gchar *invalid; GtkWidget *label; gchar* tmpstr; gchar *strdate; gsb_real number; if ( !gtk_tree_selection_get_selected ( gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) ), &model, &iter ) ) return FALSE; gtk_tree_model_get ( GTK_TREE_MODEL (model), &iter, LINK_NUMBER_COLUMN, &link_number, -1 ); /* normally should not happen */ if (!link_number) return FALSE; combobox_1 = g_object_get_data ( G_OBJECT (model), "combobox_1" ); combobox_2 = g_object_get_data ( G_OBJECT (model), "combobox_2" ); exchange_entry = g_object_get_data ( G_OBJECT (model), "exchange_entry" ); number = utils_real_get_from_string ( gtk_entry_get_text ( GTK_ENTRY (exchange_entry) ) ); if ( number.exponent > 8 ) gtk_entry_set_max_length (GTK_ENTRY (exchange_entry), strlen( gtk_entry_get_text ( GTK_ENTRY ( exchange_entry ) ) - 1) ); gsb_data_currency_link_set_first_currency ( link_number, gsb_currency_get_currency_from_combobox (combobox_1)); gsb_data_currency_link_set_second_currency ( link_number, gsb_currency_get_currency_from_combobox (combobox_2)); gsb_data_currency_link_set_change_rate ( link_number, number ); gsb_data_currency_link_set_modified_date ( link_number, gdate_today ( ) ); strdate = gsb_format_gdate ( gsb_data_currency_link_get_modified_date ( link_number ) ); if ( gsb_data_currency_link_get_invalid_link (link_number)) invalid = GTK_STOCK_DIALOG_WARNING; else invalid = NULL; tmpstr = utils_real_get_string ( gsb_data_currency_link_get_change_rate ( link_number ) ); gtk_list_store_set ( GTK_LIST_STORE (model), &iter, LINK_CURRENCY1_COLUMN, gsb_data_currency_get_name (gsb_data_currency_link_get_first_currency(link_number)), LINK_EXCHANGE_COLUMN, tmpstr, LINK_CURRENCY2_COLUMN, gsb_data_currency_get_name (gsb_data_currency_link_get_second_currency(link_number)), LINK_DATE_COLUMN, strdate, LINK_INVALID_COLUMN, invalid, -1 ); g_free ( tmpstr ); g_free ( strdate ); /* set or hide the warning label */ label = g_object_get_data (G_OBJECT (model), "warning_label"); if ( gsb_data_currency_link_get_invalid_link (link_number)) { gtk_label_set_markup ( GTK_LABEL (label), gsb_data_currency_link_get_invalid_message (link_number)); gtk_widget_show (label); } else gtk_widget_hide (label); gsb_file_set_modified ( TRUE ); gsb_gui_navigation_update_home_page ( ); return FALSE; }
/** popup a calendar next to the entry * * \param entry the date entry * * \return a GtkWindow wich contains the calendar * */ GtkWidget *gsb_calendar_entry_popup ( GtkWidget *entry ) { GtkWidget *popup, *pVBox, *pCalendar, *button, *frame; GtkRequisition *popup_size; gint x, y; gint screen_width = gdk_screen_width ( ); GDate * date; /* make the popup */ popup = gtk_window_new ( GTK_WINDOW_TOPLEVEL ); gtk_window_set_modal ( GTK_WINDOW ( popup ), TRUE ); gtk_window_set_transient_for ( GTK_WINDOW ( popup ), GTK_WINDOW ( run.window ) ); gtk_window_set_decorated ( GTK_WINDOW ( popup ), FALSE ); g_signal_connect_swapped ( G_OBJECT ( popup ), "destroy", G_CALLBACK ( gdk_pointer_ungrab ), GDK_CURRENT_TIME ); /* set the decoration */ frame = gtk_frame_new ( NULL ); gtk_container_add ( GTK_CONTAINER ( popup ), frame ); gtk_widget_show ( frame ); pVBox = gtk_vbox_new ( FALSE, 5 ); gtk_container_set_border_width ( GTK_CONTAINER ( pVBox ), 5 ); gtk_container_add ( GTK_CONTAINER ( frame ), pVBox ); gtk_widget_show ( pVBox ); /* get the date */ date = gsb_calendar_entry_get_date (entry); if (!date) date = gdate_today (); /* set the calendar */ pCalendar = gtk_calendar_new(); gtk_calendar_select_month ( GTK_CALENDAR ( pCalendar ), g_date_get_month ( date ) - 1, g_date_get_year ( date ) ); gtk_calendar_select_day ( GTK_CALENDAR ( pCalendar ), g_date_get_day ( date ) ); g_signal_connect ( G_OBJECT ( pCalendar ), "day_selected_double_click", G_CALLBACK ( gsb_calendar_entry_select_date ), entry ); g_signal_connect ( G_OBJECT ( pCalendar ), "key-press-event", G_CALLBACK ( gsb_calendar_entry_calendar_key_press ), entry ); gtk_box_pack_start ( GTK_BOX ( pVBox ), pCalendar, TRUE, TRUE, 0 ); gtk_widget_show ( pCalendar ); /* cancel button */ button = gtk_button_new_with_label ( _("Cancel") ); g_signal_connect_swapped ( G_OBJECT ( button ), "clicked", G_CALLBACK ( gtk_widget_destroy ), G_OBJECT ( popup )); gtk_box_pack_start ( GTK_BOX ( pVBox ), button, TRUE, TRUE, 0 ); gtk_widget_show ( button ); /* set the position */ gdk_window_get_origin ( GTK_WIDGET ( entry ) -> window, &x, &y ); /* on récupère la taille de la popup */ popup_size = g_malloc0 ( sizeof ( GtkRequisition )); gtk_widget_size_request ( GTK_WIDGET ( popup ), popup_size ); /* pour la soustraire à la position de l'entrée date */ y -= popup_size -> height; /* on décale le popup si on est trop près de bord droit de l'écran */ if ( x > ( screen_width - popup_size -> width ) ) x = screen_width - popup_size -> width - 10; /* si une des coordonnées est négative, alors la fonction gtk_window_move échoue et affiche la popup en 0,0 */ if ( x < 0 ) x = 0 ; if ( y < 0 ) y = 0 ; gtk_window_move ( GTK_WINDOW ( popup ), x, y ); gtk_widget_show ( popup ); gtk_widget_grab_focus ( GTK_WIDGET ( pCalendar ) ); return ( popup ); }
/** * check the scheduled transactions if the are in time limit * and record the automatic transactions * * \param * * \return * */ void gsb_scheduler_check_scheduled_transactions_time_limit ( void ) { GDate *date; GSList *tmp_list; gboolean automatic_transactions_taken = FALSE; devel_debug (NULL); /* the scheduled transactions to take will be check here, * but the scheduled transactions taken will be add to the already appended ones */ scheduled_transactions_to_take = NULL; /* get the date today + nb_days_before_scheduled */ /* the date untill we execute the scheduled transactions is : * - either today + nb_days_before_scheduled if warn n days before the scheduled * - either the end of the month in nb_days_before_scheduled days (so current month or next month) * */ date = gdate_today (); g_date_add_days ( date, nb_days_before_scheduled ); /* now date is in nb_days_before_scheduled, if we want the transactions of the month, * we change date to the end of its month */ if (execute_scheduled_of_month) { gint last_day; last_day = g_date_get_days_in_month ( g_date_get_month (date), g_date_get_year (date)); g_date_set_day (date, last_day); } /* check all the scheduled transactions, * if automatic, it's taken * if manual, appended into scheduled_transactions_to_take */ tmp_list = gsb_data_scheduled_get_scheduled_list (); while ( tmp_list ) { gint scheduled_number; scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data); /* we check that scheduled transaction only if it's not a child of a split */ if ( !gsb_data_scheduled_get_mother_scheduled_number (scheduled_number) && gsb_data_scheduled_get_date (scheduled_number) && g_date_compare ( gsb_data_scheduled_get_date (scheduled_number), date ) <= 0 ) { if ( gsb_data_scheduled_get_automatic_scheduled (scheduled_number)) { /* this is an automatic scheduled, we get it */ gint transaction_number; /* take automatically the scheduled transaction untill today */ transaction_number = gsb_scheduler_create_transaction_from_scheduled_transaction (scheduled_number, 0 ); if ( gsb_data_scheduled_get_split_of_scheduled (scheduled_number)) gsb_scheduler_execute_children_of_scheduled_transaction ( scheduled_number, transaction_number ); scheduled_transactions_taken = g_slist_append ( scheduled_transactions_taken, GINT_TO_POINTER (transaction_number)); automatic_transactions_taken = TRUE; /* set the scheduled transaction to the next date, * if it's not finished, we check them again if it need to be * executed more than one time (the easiest way is to check * all again, i don't think it will have thousand of scheduled transactions, * so no much waste of time...) */ if (gsb_scheduler_increase_scheduled (scheduled_number)) { scheduled_transactions_to_take = NULL; tmp_list = gsb_data_scheduled_get_scheduled_list (); } else /* the scheduled is finish, so we needn't to check it again ... */ tmp_list = tmp_list -> next; } else { /* it's a manual scheduled transaction, we put it in the slist */ scheduled_transactions_to_take = g_slist_append ( scheduled_transactions_to_take , GINT_TO_POINTER (scheduled_number)); tmp_list = tmp_list -> next; } } else tmp_list = tmp_list -> next; } if ( automatic_transactions_taken ) { mise_a_jour_liste_echeances_auto_accueil = 1; gsb_file_set_modified ( TRUE ); } if ( scheduled_transactions_to_take ) mise_a_jour_liste_echeances_manuelles_accueil = 1; g_date_free ( date ); }
gchar *etats_titre ( gint report_number) { gchar *titre; GDate *today_date; titre = gsb_data_report_get_report_name (report_number); today_date = gdate_today (); if ( gsb_data_report_get_use_financial_year (report_number)) { GSList *tmp_list; gint fyear_number; gint last_fyear_number; switch (gsb_data_report_get_financial_year_type (report_number)) { case 0: /* all the financial years */ titre = g_strconcat ( titre, ", ", _("all financial years"), NULL ); break; case 1: /* current financial year */ fyear_number = gsb_data_fyear_get_from_date (today_date); if (fyear_number) titre = g_strconcat ( titre, ", ", _("current financial year") , " (", gsb_data_fyear_get_name (fyear_number), ")", NULL ); else titre = g_strconcat ( titre, ", ", _("current financial year"), NULL ); break; case 2: /* last financial year */ fyear_number = gsb_data_fyear_get_from_date (today_date); last_fyear_number = 0; tmp_list = gsb_data_fyear_get_fyears_list (); while (tmp_list) { gint tmp_fyear_number; tmp_fyear_number = gsb_data_fyear_get_no_fyear (tmp_list -> data); if (gsb_data_fyear_compare (fyear_number, tmp_fyear_number) == 1) { if (last_fyear_number) { if (gsb_data_fyear_compare (last_fyear_number, tmp_fyear_number) == -1) last_fyear_number = tmp_fyear_number; } else { last_fyear_number = tmp_fyear_number; } } tmp_list = tmp_list -> next; } /* here, last_fyear_number is on the last financial year */ if (last_fyear_number) titre = g_strconcat ( titre, ", ", _("former financial year") , " (", gsb_data_fyear_get_name (last_fyear_number), ")", NULL ); else titre = g_strconcat ( titre, ", ", _("former financial year"), NULL ); break; case 3: /* personal selection of financial years */ tmp_list = gsb_data_report_get_financial_year_list (report_number); if ( g_slist_length ( tmp_list ) > 1 ) titre = g_strconcat ( titre, ", ", _("financial years"), " ", NULL ); else titre = g_strconcat ( titre, ", ", _("financial year"), " ", NULL ); while ( tmp_list ) { gint fyear_number; fyear_number = GPOINTER_TO_INT (tmp_list -> data); if ( tmp_list == g_slist_last (gsb_data_report_get_financial_year_list (report_number))) titre = g_strconcat ( titre, gsb_data_fyear_get_name (fyear_number), NULL ); else titre = g_strconcat ( titre, gsb_data_fyear_get_name (fyear_number), ", ", NULL ); tmp_list = tmp_list -> next; } break; } } else { /* c'est une plage de dates qui a été entrée */ gchar buffer_date[15]; gchar buffer_date_2[15]; GDate *date_tmp; switch ( gsb_data_report_get_date_type (report_number)) { case 0: /* toutes */ titre = g_strconcat ( titre, ", ", _("all dates"), NULL ); break; case 1: /* plage perso */ if ( gsb_data_report_get_personal_date_start (report_number) && gsb_data_report_get_personal_date_end (report_number)) titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("Result from %s to %s"), gsb_format_gdate ( gsb_data_report_get_personal_date_start (report_number)), gsb_format_gdate ( gsb_data_report_get_personal_date_end (report_number)) ), NULL ); else titre = g_strconcat ( titre, ", ", _("Custom dates ranges not filled"), NULL ); break; case 2: /* cumul à ce jour */ titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("total at %s"), gsb_format_gdate (today_date)), NULL ); break; case 3: /* mois en cours */ g_date_strftime ( buffer_date, 14, "%B", today_date ); titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("%s %d"), buffer_date, g_date_get_year (today_date)), NULL ); break; case 4: /* année en cours */ titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("year %d"), g_date_get_year (today_date)), NULL ); break; case 5: /* cumul mensuel */ titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("month total at %s"), gsb_format_gdate (today_date)), NULL ); break; case 6: /* cumul annuel */ titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("year total at %s"), gsb_format_gdate (today_date)), NULL ); break; case 7: /* mois précédent */ g_date_subtract_months ( today_date, 1 ); g_date_strftime ( buffer_date, 14, "%B", today_date ); titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("%s %d"), buffer_date, g_date_get_year (today_date)), NULL ); break; case 8: /* année précédente */ titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("year %d"), g_date_get_year (today_date) - 1), NULL ); break; case 9: /* 30 derniers jours */ date_tmp = gdate_today ( ); g_date_subtract_days ( date_tmp, 30 ); titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("Result from %s to %s"), gsb_format_gdate ( date_tmp ), gsb_format_gdate (today_date)), NULL ); break; case 10: /* 3 derniers mois */ date_tmp = gdate_today ( ); g_date_subtract_months ( date_tmp, 3 ); g_date_strftime ( buffer_date_2, 14, "%B", date_tmp ); g_date_strftime ( buffer_date, 14, "%B", today_date); titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("from %s %d"), buffer_date_2, g_date_get_year ( date_tmp )), " ", g_strdup_printf ( _("to %s %d"), buffer_date, g_date_get_year (today_date)), NULL ); break; case 11: /* 6 derniers mois */ date_tmp = gdate_today ( ); g_date_subtract_months ( date_tmp, 6 ); g_date_strftime ( buffer_date_2, 14, "%B", date_tmp ); g_date_strftime ( buffer_date, 14, "%B", today_date); titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("from %s %d"), buffer_date_2, g_date_get_year ( date_tmp )), " ", g_strdup_printf ( _("to %s %d"), buffer_date, g_date_get_year (today_date)), NULL ); break; case 12: /* 12 derniers mois */ date_tmp = gdate_today ( ); g_date_subtract_months ( date_tmp, 12 ); g_date_strftime ( buffer_date_2, 14, "%B", date_tmp ); g_date_strftime ( buffer_date, 14, "%B", today_date); titre = g_strconcat ( titre, ", ", g_strdup_printf ( _("from %s %d"), buffer_date_2, g_date_get_year ( date_tmp )), " ", g_strdup_printf ( _("to %s %d"), buffer_date, g_date_get_year (today_date)), NULL ); break; } } return titre; }