]> saetta.ns0.it Git - libgtkform/commitdiff
Added function GtkFormFieldDateTime::get_gdate_from_tm.
authorAndrea Zagli <azagli@libero.it>
Thu, 10 Sep 2009 15:24:07 +0000 (17:24 +0200)
committerAndrea Zagli <azagli@libero.it>
Thu, 10 Sep 2009 15:24:07 +0000 (17:24 +0200)
src/fielddatetime.c
src/fielddatetime.h

index 253862113217a3983c80f639453e4287c792a3f2..8f50faf74e97573c67dd81810923d700edc464e5 100644 (file)
@@ -525,6 +525,34 @@ gchar
        return ret;
 }
 
+/**
+ * gtk_form_field_datetime_get_gdate_from_tm:
+ * @datetime: a struct tm.
+ *
+ * Returns: a #GDate that represent the struct tm without time information.
+ */
+GDate
+*gtk_form_field_datetime_get_gdate_from_tm (struct tm *datetime)
+{
+       GDate *ret;
+
+       ret = NULL;
+
+       if (datetime != NULL)
+               {
+                       ret = g_date_new_dmy (datetime->tm_mday,
+                                             datetime->tm_mon + 1,
+                                             datetime->tm_year + 1900);
+
+                       if (!g_date_valid (ret))
+                               {
+                                       ret = NULL;
+                               }
+               }
+
+       return ret;
+}
+
 /* PRIVATE */
 static void
 gtk_form_field_datetime_set_property (GObject *object,
index a3acef96eca2c99ced79d58b6b883e5f1b93558e..7439447f2efc7e12b8058e750f2eb926dafe57ab 100644 (file)
@@ -75,6 +75,8 @@ gboolean gtk_form_field_datetime_set_from_datamodel (GtkFormField *field, GdaDat
 struct tm *gtk_form_field_datetime_get_tm_from_str (const gchar *str, const gchar *format);
 gchar *gtk_form_field_datetime_get_str_from_tm (struct tm *datetime, const gchar *format);
 
+GDate *gtk_form_field_datetime_get_gdate_from_tm (struct tm *datetime);
+
 
 G_END_DECLS