tm.tm_year = val / 10000 - 1900;
}
- if (*iso_date++ != 'T')
+ if (*iso_date != 'T')
+ {
+ /* Date only */
+ if (*iso_date == '\0')
+ return TRUE;
+ return FALSE;
+ }
+
+ *iso_date++;
+
+ /* If there is a 'T' then there has to be a time */
+ if (!g_ascii_isdigit (*iso_date))
return FALSE;
-
+
val = strtoul (iso_date, (char **)&iso_date, 10);
if (*iso_date == ':')
{
#define REF_INVALID1 "Wed Dec 19 17:20:20 GMT 2007"
#define REF_INVALID2 "1980-02-22T10:36:00Zulu"
+#define REF_INVALID3 "1980-02-22T"
#define REF_SEC_UTC 320063760
#define REF_STR_UTC "1980-02-22T10:36:00Z"
#define REF_STR_LOCAL "1980-02-22T13:36:00"
#define REF_STR_USEC_CEST "19800222T123600.050000000+0200"
#define REF_STR_USEC_EST "1980-02-22T05:36:00,05-05:00"
#define REF_STR_USEC_NST "19800222T070600,0500-0330"
+#define REF_STR_DATE_ONLY "1980-02-22"
if (g_test_verbose())
g_print ("checking g_time_val_from_iso8601...\n");
ref_date.tv_usec = 0;
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_UTC, &date) != FALSE);
if (g_test_verbose())
g_print ("\t=> UTC stamp = %ld.%06ld (should be: %ld.%06ld) (%ld.%06ld off)\n",