From: Andrea Zagli Date: Mon, 4 Jul 2011 10:18:25 +0000 (+0200) Subject: Aggiunte le funzioni Solipa::gdatetime_to_tm e Solipa::gtk_tree_model_get_value_gdate... X-Git-Tag: 0.5.0~54 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=c42e5e341815cda97b3d5205d02a1fb0fea07bf2;p=solipa%2Flibsolipa Aggiunte le funzioni Solipa::gdatetime_to_tm e Solipa::gtk_tree_model_get_value_gdatetime. --- diff --git a/src/utils.c b/src/utils.c index 69347df..63cb7fa 100644 --- a/src/utils.c +++ b/src/utils.c @@ -29,9 +29,6 @@ #include #include -#include -#include - #include "solipa.h" #include "utils.h" @@ -661,6 +658,22 @@ GDateTime return ret; } +struct tm +*solipa_gdatetime_to_tm (GDateTime *gdatetime) +{ + struct tm *ret; + + ret = g_new0 (struct tm, 1); + ret->tm_year = g_date_time_get_year (gdatetime) - 1900; + ret->tm_mon = g_date_time_get_month (gdatetime) - 1; + ret->tm_mday = g_date_time_get_day_of_week (gdatetime); + ret->tm_hour = g_date_time_get_hour (gdatetime); + ret->tm_min = g_date_time_get_minute (gdatetime); + ret->tm_sec = g_date_time_get_second (gdatetime); + + return ret; +} + const gchar *solipa_tm_to_sql (struct tm *tm_data, const gchar *format) { @@ -927,11 +940,24 @@ struct tm *solipa_gtk_tree_model_get_value_tm (GtkTreeModel *model, GtkTreeIter *iter, gint column, const gchar *format) { struct tm *ret; + GDateTime *dt; + + dt = solipa_gtk_tree_model_get_value_gdatetime (model, iter, column, format); + + ret = solipa_gdatetime_to_tm (dt); + + return ret; +} + +GDateTime +*solipa_gtk_tree_model_get_value_gdatetime (GtkTreeModel *model, GtkTreeIter *iter, gint column, const gchar *format) +{ + GDateTime *ret; const gchar *value; value = solipa_gtk_tree_model_get_value_string (model, iter, column); - ret = gtk_form_field_datetime_get_tm_from_str (value, format); + ret = solipa_get_gdatetime_from_string (value, format); return ret; } diff --git a/src/utils.h b/src/utils.h index 3e283e0..0bf506d 100644 --- a/src/utils.h +++ b/src/utils.h @@ -59,6 +59,7 @@ struct tm *solipa_get_now_tm (void); GDate *solipa_get_today_gdate (void); GDateTime *solipa_tm_to_gdatetime (struct tm *tm_data); +struct tm *solipa_gdatetime_to_tm (GDateTime *gdatetime); const gchar *solipa_tm_to_sql (struct tm *tm_data, const gchar *format); GDateTime *solipa_get_gdatetime_from_string (const gchar *string, const gchar *format); @@ -70,6 +71,7 @@ gint solipa_gtk_tree_model_get_value_integer (GtkTreeModel *model, GtkTreeIter * gdouble solipa_gtk_tree_model_get_value_double (GtkTreeModel *model, GtkTreeIter *iter, gint column); const gchar *solipa_gtk_tree_model_get_value_double_sql (GtkTreeModel *model, GtkTreeIter *iter, gint column); struct tm *solipa_gtk_tree_model_get_value_tm (GtkTreeModel *model, GtkTreeIter *iter, gint column, const gchar *format); +GDateTime *solipa_gtk_tree_model_get_value_gdatetime (GtkTreeModel *model, GtkTreeIter *iter, gint column, const gchar *format); gboolean solipa_chk_codice_fiscale (const gchar *codice_fiscale, gboolean empty_good); gboolean solipa_chk_partita_iva (const gchar *partita_iva, gboolean empty_good);