[glib] Remove broken attempt at parsing date-only



commit 27e352985bf0734e9209e8052dc966a05e6bfae1
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 29 13:43:28 2013 -0500

    Remove broken attempt at parsing date-only
    
    g_time_val_from_iso8601 was attempting to parse strings
    having only a date, but failed to actually set the timeval
    despite returning TRUE. Since the docs state that the function
    only parses strings containing a date and a time, just return
    FALSE in this case.
    
    Also remove an incomplete testcase for this behaviour that was
    just checking the boolean return value, but not timeval.

 glib/gtimer.c    |   17 ++++++-----------
 tests/testglib.c |    2 +-
 2 files changed, 7 insertions(+), 12 deletions(-)
---
diff --git a/glib/gtimer.c b/glib/gtimer.c
index f1bef07..3273627 100644
--- a/glib/gtimer.c
+++ b/glib/gtimer.c
@@ -299,8 +299,8 @@ g_time_val_add (GTimeVal *time_, glong microseconds)
     }
 }
 
-/* converts a broken down date representation, relative to UTC, to
- * a timestamp; it uses timegm() if it's available.
+/* converts a broken down date representation, relative to UTC,
+ * to a timestamp; it uses timegm() if it's available.
  */
 static time_t
 mktime_utc (struct tm *tm)
@@ -360,9 +360,9 @@ g_time_val_from_iso8601 (const gchar *iso_date,
   g_return_val_if_fail (iso_date != NULL, FALSE);
   g_return_val_if_fail (time_ != NULL, FALSE);
 
-  /* Ensure that the first character is a digit,
-   * the first digit of the date, otherwise we don't
-   * have an ISO 8601 date */
+  /* Ensure that the first character is a digit, the first digit
+   * of the date, otherwise we don't have an ISO 8601 date
+   */
   while (g_ascii_isspace (*iso_date))
     iso_date++;
 
@@ -394,12 +394,7 @@ g_time_val_from_iso8601 (const gchar *iso_date,
     }
 
   if (*iso_date != 'T')
-    {
-      /* Date only */
-      if (*iso_date == '\0')
-        return TRUE;
-      return FALSE;
-    }
+    return FALSE;
 
   iso_date++;
 
diff --git a/tests/testglib.c b/tests/testglib.c
index a004b65..9894c3a 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -1347,7 +1347,7 @@ various_string_tests (void)
   g_assert (g_time_val_from_iso8601 (REF_INVALID1, &date) == FALSE);
   g_assert (g_time_val_from_iso8601 (REF_INVALID2, &date) == FALSE);
   g_assert (g_time_val_from_iso8601 (REF_INVALID3, &date) == FALSE);
-  g_assert (g_time_val_from_iso8601 (REF_STR_DATE_ONLY, &date) != FALSE);
+  g_assert (g_time_val_from_iso8601 (REF_STR_DATE_ONLY, &date) == FALSE);
   g_assert (g_time_val_from_iso8601 (REF_STR_UTC, &date) != FALSE);
   if (g_test_verbose())
     g_print ("\t=> UTC stamp = %ld.%06ld (should be: %ld.%06ld) (%ld.%06ld off)\n",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]