time_->tv_sec = mktime_utc (&tm);
time_->tv_usec = 0;
- if (*iso_date == '.')
+ if (*iso_date == ',' || *iso_date == '.')
{
glong mul = 100000;
{
gint sign = (*iso_date == '+') ? -1 : 1;
- val = 60 * strtoul (iso_date + 1, (char **)&iso_date, 10);
+ val = strtoul (iso_date + 1, (char **)&iso_date, 10);
if (*iso_date == ':')
val = 60 * val + strtoul (iso_date + 1, (char **)&iso_date, 10);
else
val = 60 * (val / 100) + (val % 100);
- time_->tv_sec += (time_t) (val * sign);
+ time_->tv_sec += (time_t) (60 * val * sign);
}
else if (*iso_date++ != 'Z')
return FALSE;
#define REF_STR_UTC "1980-02-22T10:36:00Z"
#define REF_STR_CEST "1980-02-22T12:36:00+02:00"
#define REF_STR_EST "19800222T053600-0500"
+#define REF_STR_NST "1980-02-22T07:06:00-03:30"
#define REF_USEC_UTC 50000
#define REF_STR_USEC_UTC "1980-02-22T10:36:00.050000Z"
#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_EST "1980-02-22T05:36:00,05-05:00"
+#define REF_STR_USEC_NST "19800222T070600,0500-0330"
if (g_test_verbose())
g_print ("checking g_time_val_from_iso8601...\n");
date.tv_sec - ref_date.tv_sec, date.tv_usec - ref_date.tv_usec);
g_assert (date.tv_sec == ref_date.tv_sec && date.tv_usec == ref_date.tv_usec);
+ g_assert (g_time_val_from_iso8601 (REF_STR_NST, &date) != FALSE);
+ if (g_test_verbose())
+ g_print ("\t=> NST stamp = %ld.%06ld (should be: %ld.%06ld) (%ld.%06ld off)\n",
+ date.tv_sec, date.tv_usec, ref_date.tv_sec, ref_date.tv_usec,
+ date.tv_sec - ref_date.tv_sec, date.tv_usec - ref_date.tv_usec);
+ g_assert (date.tv_sec == ref_date.tv_sec && date.tv_usec == ref_date.tv_usec);
+
ref_date.tv_usec = REF_USEC_UTC;
g_assert (g_time_val_from_iso8601 (REF_STR_USEC_UTC, &date) != FALSE);
if (g_test_verbose())
date.tv_sec - ref_date.tv_sec, date.tv_usec - ref_date.tv_usec);
g_assert (date.tv_sec == ref_date.tv_sec && date.tv_usec == ref_date.tv_usec);
+ g_assert (g_time_val_from_iso8601 (REF_STR_USEC_NST, &date) != FALSE);
+ if (g_test_verbose())
+ g_print ("\t=> NST stamp = %ld.%06ld (should be: %ld.%06ld) (%ld.%06ld off)\n",
+ date.tv_sec, date.tv_usec, ref_date.tv_sec, ref_date.tv_usec,
+ date.tv_sec - ref_date.tv_sec, date.tv_usec - ref_date.tv_usec);
+ g_assert (date.tv_sec == ref_date.tv_sec && date.tv_usec == ref_date.tv_usec);
+
if (g_test_verbose())
g_print ("checking g_time_val_to_iso8601...\n");
ref_date.tv_sec = REF_SEC_UTC;