summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Muscat <jrem@corefiling.com>2012-09-04 20:18:04 +0800
committerDaniel Veillard <veillard@redhat.com>2012-09-04 20:18:04 +0800
commit4ad8f1215e624188416d0f913cad972b9807614e (patch)
tree3d08444f0a164602dbbf26b9e56a409df1e7791a
parentaebfee35d1106035dddf897e0e81d72d110b5e63 (diff)
downloadlibxslt-4ad8f1215e624188416d0f913cad972b9807614e.tar.gz
libxslt-4ad8f1215e624188416d0f913cad972b9807614e.tar.bz2
libxslt-4ad8f1215e624188416d0f913cad972b9807614e.zip
EXSLT date normalization fix
https://bugzilla.gnome.org/show_bug.cgi?id=626855 Dates with timezones but no time components are not normalized correctly Using xsltproc v1.1.26: $ xsltproc --version Using libxml 20706, libxslt 10126 and libexslt 815 xsltproc was compiled against libxml 20704, libxslt 10126 and libexslt 815 libxslt 10126 was compiled against libxml 20704 libexslt 815 was compiled against libxml 20704 Dates that have timezone offsets specified but no time components, for example "1970-01-01+01:00", are not normalized correctly; the timezone part is truncated: date:seconds("1970-01-01") = 0 date:seconds("1970-01-01+01:00") = 0 (not -3600 as expected) Alters the conditions under which exsltDateNormalize() returns without normalizing, and adds test cases demonstrating the new behaviour.
-rw-r--r--libexslt/date.c2
-rw-r--r--tests/exslt/date/seconds.1.out16
-rw-r--r--tests/exslt/date/seconds.1.xml9
3 files changed, 26 insertions, 1 deletions
diff --git a/libexslt/date.c b/libexslt/date.c
index b692bb42..18523d02 100644
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -1602,7 +1602,7 @@ exsltDateNormalize (exsltDateValPtr dt)
if (dt == NULL)
return;
- if (((dt->type & XS_TIME) != XS_TIME) || (dt->value.date.tzo == 0))
+ if (((dt->type & XS_TIME) != XS_TIME) && (dt->value.date.tzo == 0))
return;
dur = exsltDateCreateDate(XS_DURATION);
diff --git a/tests/exslt/date/seconds.1.out b/tests/exslt/date/seconds.1.out
index 3447bf87..c0eb72c0 100644
--- a/tests/exslt/date/seconds.1.out
+++ b/tests/exslt/date/seconds.1.out
@@ -35,3 +35,19 @@ seconds : 0001-01-01T00:00:00
result : -6.21355968e+10
seconds : -0001-01-01T00:00:00
result : -6.21671328e+10
+seconds : 1970-01-01
+result : 0
+seconds : 1970-01-01Z
+result : 0
+seconds : 1970-01-01-11:00
+result : 39600
+seconds : 1970-01-01+11:00
+result : -39600
+seconds : 1970-01-01-12:00
+result : 43200
+seconds : 1970-01-01+12:00
+result : -43200
+seconds : 1970-01-01-13:00
+result : 46800
+seconds : 1970-01-01+13:00
+result : -46800
diff --git a/tests/exslt/date/seconds.1.xml b/tests/exslt/date/seconds.1.xml
index 5e0a664f..24d58fb2 100644
--- a/tests/exslt/date/seconds.1.xml
+++ b/tests/exslt/date/seconds.1.xml
@@ -20,5 +20,14 @@
<date duration="1971-01-01T00:00:00"/>
<date duration="0001-01-01T00:00:00"/>
<date duration="-0001-01-01T00:00:00"/>
+ <!-- timezones -->
+ <date duration="1970-01-01" />
+ <date duration="1970-01-01Z" />
+ <date duration="1970-01-01-11:00" />
+ <date duration="1970-01-01+11:00" />
+ <date duration="1970-01-01-12:00" />
+ <date duration="1970-01-01+12:00" />
+ <date duration="1970-01-01-13:00" />
+ <date duration="1970-01-01+13:00" />
</page>