From 89d0e185205750d54b684eebd7345dc8d5e5b1e1 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 26 Nov 2011 10:36:41 +0100 Subject: [PATCH] Aggiunte alcune funzioni di conversione da e di GDate (closes #217). --- .anjuta/default.profile | 8 ++-- .anjuta/session/anjuta.session | 7 ++- .anjuta/session/dock-layout.xml | 2 +- .anjuta_sym_db.db | Bin 983040 -> 983040 bytes src/utils.c | 75 +++++++++++++++++++++++++++++++- src/utils.h | 6 +++ 6 files changed, 89 insertions(+), 9 deletions(-) diff --git a/.anjuta/default.profile b/.anjuta/default.profile index 6937de0..fab0d87 100644 --- a/.anjuta/default.profile +++ b/.anjuta/default.profile @@ -1,14 +1,14 @@ - + + value="anjuta-terminal:TerminalPlugin"/> - + + value="anjuta-tools:ATPPlugin"/> \n\n diff --git a/.anjuta/session/dock-layout.xml b/.anjuta/session/dock-layout.xml index b35c6db..b5b3e4d 100644 --- a/.anjuta/session/dock-layout.xml +++ b/.anjuta/session/dock-layout.xml @@ -1,2 +1,2 @@ - + diff --git a/.anjuta_sym_db.db b/.anjuta_sym_db.db index 1dba8fde0d6281cba3fb69748a36d8e200f6b75e..6f5d3cead9ac4ac4af1216b20c0c2d0b267f59c0 100644 GIT binary patch delta 7285 zcmaJmdt6l2)@PqHduAAC4xqz;z%T=dJmn!Mil87M@=!6wG`fuw9FWH_zzhfia}c!0 z_fxM~-BtI?u68SXd_A;ms_SQ(m5+R6UA1m?v%d22GtD&ffiU0R=kOG7e{lAiwbx#I z?e*GgZ8|&CJ3G@i2C}H&vEbR{yL$P~>{F%s+KLvay;-t{}M6|2m71kNh{8aNwho{_BjutoZthy!aDIc zY+=b?R^vE*W#_z?Dju+Htcb3dUy*T-@4Q_#FGJ>P{J6NO@~w79<)%uZg0JW+e@8SG zrB?h@{!C3n^=qQDYHq>xw)cw071kH(+fH?yU12J`T$toaTv6*PUh#5ckKk(DFU&1C zUhs-bwIZu=oiL{HRUuYPtI}2)%8$7=thmsTQ~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b9 100644 --- a/src/utils.c +++ b/src/utils.c @@ -880,17 +880,62 @@ struct tm return ret; } +GDateTime +*solipa_gdate_to_gdatetime (GDate *gdate) +{ + GDateTime *ret; + + ret = NULL; + if (g_date_valid (gdate)) + { + ret = g_date_time_new_local (g_date_get_year (gdate), + g_date_get_month (gdate), + g_date_get_day (gdate), + 0, 0, 0.0); + } + + return ret; +} + +GDate +*solipa_gdatetime_to_gdate (GDateTime *gdatetime) +{ + GDate *ret; + + ret = g_new0 (GDate, 1); + g_date_set_year (ret, g_date_time_get_year (gdatetime)); + g_date_set_month (ret, g_date_time_get_month (gdatetime)); + g_date_set_day (ret, g_date_time_get_day_of_month (gdatetime)); + + return ret; +} + const gchar *solipa_tm_to_sql (struct tm *tm_data, const gchar *format) { const gchar *ret; - gchar *_format; ret = g_strdup ("NULL"); if (tm_data != NULL) { - ret = solipa_gdatetime_to_sql (solipa_tm_to_gdatetime (tm_data), _format); + ret = solipa_gdatetime_to_sql (solipa_tm_to_gdatetime (tm_data), format); + } + + return ret; +} + + +const gchar +*solipa_gdate_to_sql (GDate *gdate, const gchar *format) +{ + const gchar *ret; + + ret = g_strdup ("NULL"); + + if (g_date_valid (gdate)) + { + ret = solipa_gdatetime_to_sql (solipa_gdate_to_gdatetime (gdate), format); } return ret; @@ -933,6 +978,18 @@ const gchar return ret; } +GDate +*solipa_get_gdate_from_string (const gchar *string, const gchar *format) +{ + GDate *ret; + + GDateTime *gdatetime; + + gdatetime = solipa_get_gdatetime_from_string (string, format); + + ret = solipa_gdatetime_to_gdate (gdatetime); +} + GDateTime *solipa_get_gdatetime_from_string (const gchar *string, const gchar *format) { @@ -1085,6 +1142,8 @@ GDateTime } } + g_strfreev (format_tokens); + g_strfreev (str_tokens); g_free (delimiters); g_free (new_format); g_free (new_str); @@ -1102,6 +1161,18 @@ GDateTime return ret; } +gchar +*solipa_gdate_format (GDate *gdate, const gchar *format) +{ + gchar *ret; + + if (g_date_valid (gdate)) return ""; + + ret = solipa_gdatetime_format (solipa_gdate_to_gdatetime (gdate), format); + + return ret; +} + gchar *solipa_gdatetime_format (GDateTime *gdatetime, const gchar *format) { diff --git a/src/utils.h b/src/utils.h index 3669859..7312840 100644 --- a/src/utils.h +++ b/src/utils.h @@ -64,10 +64,16 @@ GDate *solipa_get_today_gdate (void); GDateTime *solipa_tm_to_gdatetime (struct tm *tm_data); struct tm *solipa_gdatetime_to_tm (GDateTime *gdatetime); +GDateTime *solipa_gdate_to_gdatetime (GDate *gdate); +GDate *solipa_gdatetime_to_gdate (GDateTime *gdatetime); + const gchar *solipa_tm_to_sql (struct tm *tm_data, const gchar *format); +const gchar *solipa_gdate_to_sql (GDate *gdate, const gchar *format); const gchar *solipa_gdatetime_to_sql (GDateTime *gdatetime, const gchar *format); +GDate *solipa_get_gdate_from_string (const gchar *string, const gchar *format); GDateTime *solipa_get_gdatetime_from_string (const gchar *string, const gchar *format); +gchar *solipa_gdate_format (GDate *gdate, const gchar *format); gchar *solipa_gdatetime_format (GDateTime *gdatetime, const gchar *format); gdouble solipa_round (gdouble value, guint n_decimals); -- 2.49.0