]> saetta.ns0.it Git - zakform/libzakform/commitdiff
ZakFormValidatorCompareDate now returns true if both elements are null (closes #1016).
authorAndrea Zagli <azagli@libero.it>
Sun, 15 May 2016 09:28:43 +0000 (11:28 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 15 May 2016 09:28:43 +0000 (11:28 +0200)
src/formvalidatorcomparedate.c

index 5de341e943151674fc69c40dbfe756802e175f4d..ba0a04c38cdd7b0b22defa9d1d4447f7aa931fc5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2016 Andrea Zagli <azagli@libero.it>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -265,6 +265,11 @@ zak_form_validator_compare_date_validate (ZakFormValidator *validator)
                        gdt2 = zak_utils_get_gdatetime_from_string (zak_form_element_get_value (priv->v2), priv->format2);
 
                        if (gdt1 == NULL
+                               && gdt2 == NULL)
+                               {
+                                       return TRUE;
+                               }
+                       else if (gdt1 == NULL
                                || gdt2 == NULL)
                                {
                                        if (priv->type == LESSER
@@ -319,6 +324,15 @@ zak_form_validator_compare_date_validate (ZakFormValidator *validator)
                                        zak_form_validator_set_message (validator, msg);
                                        g_free (msg);
                                }
+
+                       if (gdt1 != NULL)
+                               {
+                                       g_date_time_unref (gdt1);
+                               }
+                       if (gdt2 != NULL)
+                               {
+                                       g_date_time_unref (gdt2);
+                               }
                }
 
        return ret;