]> saetta.ns0.it Git - libgdaex/commitdiff
Error on GDate creation (wrong parameters order).
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 22 Jan 2013 16:05:50 +0000 (17:05 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Tue, 22 Jan 2013 16:05:50 +0000 (17:05 +0100)
src/gdaex.c

index a977d2180e4a87dc0e3b2d836eded5a3fc2e2704..c843e5da5c93c236272468a29e28a4ca34cbb3d8 100644 (file)
@@ -1336,16 +1336,16 @@ GDate
                                        if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
                                                {
                                                        gdatimestamp = gdaex_data_model_get_value_gdatimestamp_at (data_model, row, col);
-                                                       ret = g_date_new_dmy ((GDateYear)gdatimestamp->year,
+                                                       ret = g_date_new_dmy ((GDateYear)gdatimestamp->day,
                                                                              (GDateMonth)gdatimestamp->month,
-                                                                             (GDateDay)gdatimestamp->day);
+                                                                             (GDateDay)gdatimestamp->year);
                                                }
                                        else if (gda_value_isa (v, G_TYPE_DATE_TIME))
                                                {
                                                        gdatetime = gdaex_data_model_get_value_gdatetime_at (data_model, row, col);
-                                                       ret = g_date_new_dmy ((GDateYear)g_date_time_get_year ((GDateTime *)gdatetime),
+                                                       ret = g_date_new_dmy ((GDateYear)g_date_time_get_day_of_month ((GDateTime *)gdatetime),
                                                                              (GDateMonth)g_date_time_get_month ((GDateTime *)gdatetime),
-                                                                             (GDateDay)g_date_time_get_day_of_month ((GDateTime *)gdatetime));
+                                                                             (GDateDay)g_date_time_get_year ((GDateTime *)gdatetime));
                                                }
                                        else if (gda_value_isa (v, G_TYPE_DATE))
                                                {
@@ -2094,16 +2094,16 @@ GDate
                        if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
                                {
                                        gdatimestamp = gdaex_data_model_iter_get_value_gdatimestamp_at (iter, col);
-                                       ret = g_date_new_dmy ((GDateYear)gdatimestamp->year,
+                                       ret = g_date_new_dmy ((GDateYear)gdatimestamp->day,
                                                              (GDateMonth)gdatimestamp->month,
-                                                             (GDateDay)gdatimestamp->day);
+                                                             (GDateDay)gdatimestamp->year);
                                }
                        else if (gda_value_isa (v, G_TYPE_DATE_TIME))
                                {
                                        gdatetime = gdaex_data_model_iter_get_value_gdatetime_at (iter, col);
-                                       ret = g_date_new_dmy ((GDateYear)g_date_time_get_year ((GDateTime *)gdatetime),
+                                       ret = g_date_new_dmy ((GDateYear)g_date_time_get_day_of_month ((GDateTime *)gdatetime),
                                                              (GDateMonth)g_date_time_get_month ((GDateTime *)gdatetime),
-                                                             (GDateDay)g_date_time_get_day_of_month ((GDateTime *)gdatetime));
+                                                             (GDateDay)g_date_time_get_year ((GDateTime *)gdatetime));
                                }
                        else if (gda_value_isa (v, G_TYPE_DATE))
                                {
@@ -2132,10 +2132,8 @@ GDateTime
        const GdaTimestamp *gdatimestamp;
        const GDate *gdate;
        const GValue *v;
-       GError *error;
 
        ret = NULL;
-       error = NULL;
 
        v = gda_data_model_iter_get_value_at (iter, col);
        if (v == NULL)
@@ -2152,22 +2150,28 @@ GDateTime
                        if (gda_value_isa (v, GDA_TYPE_TIMESTAMP))
                                {
                                        gdatimestamp = gdaex_data_model_iter_get_value_gdatimestamp_at (iter, col);
-                                       ret = g_date_time_new_local ((gint)gdatimestamp->year,
-                                                                    (gint)gdatimestamp->month,
-                                                                    (gint)gdatimestamp->day,
-                                                                    (gint)gdatimestamp->hour,
-                                                                    (gint)gdatimestamp->minute,
-                                                                    (gdouble)gdatimestamp->second);
+                                       if (gdatimestamp != NULL)
+                                               {
+                                                       ret = g_date_time_new_local ((gint)gdatimestamp->year,
+                                                                                    (gint)gdatimestamp->month,
+                                                                                    (gint)gdatimestamp->day,
+                                                                                    (gint)gdatimestamp->hour,
+                                                                                    (gint)gdatimestamp->minute,
+                                                                                    (gdouble)gdatimestamp->second);
+                                               }
                                }
                        else if (gda_value_isa (v, G_TYPE_DATE))
                                {
                                        gdate = gdaex_data_model_iter_get_value_gdate_at (iter, col);
-                                       ret = g_date_time_new_local ((gint)g_date_get_year (gdate),
-                                                                    (gint)g_date_get_month (gdate),
-                                                                    (gint)g_date_get_day (gdate),
-                                                                    0,
-                                                                    0,
-                                                                    0.0);
+                                       if (gdate != NULL && 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);
+                                               }
                                }
                        else if (gda_value_isa (v, G_TYPE_DATE_TIME))
                                {