summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Kjellerstedt <pkj@axis.com>2009-04-08 10:26:11 -0400
committerMatthias Clasen <mclasen@redhat.com>2009-04-08 10:26:11 -0400
commitefc2cdbfc981754db361f49c30c8ee24ac0c769e (patch)
treeba610330d4b420c19c484e3b1e0ee72ba740a9f6 /tests
parentd0cf7b38780b0832fc904f75eb387aa61eb2f76e (diff)
Fix parsing of timezones
Make g_time_val_from_iso8601 handle timezones with minutes correctly; also accept comma as a fraction separator. (#578369)
Diffstat (limited to 'tests')
-rw-r--r--tests/testglib.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/testglib.c b/tests/testglib.c
index 8d3a59c6f..2eeea1e8b 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -1310,10 +1310,12 @@ various_string_tests (void)
#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");
@@ -1342,6 +1344,13 @@ various_string_tests (void)
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())
@@ -1364,6 +1373,13 @@ various_string_tests (void)
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;