summaryrefslogtreecommitdiff
path: root/libexslt
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2007-10-10 14:34:38 +0000
committerDaniel Veillard <veillard@src.gnome.org>2007-10-10 14:34:38 +0000
commitc21fe206b08ec948a70edcd24ba5030d7634fab9 (patch)
tree600f1a523f4ab1c6c1a425d80af6bd661f4ac2a6 /libexslt
parente513120fb960095941b394f30461df18b81ff9f6 (diff)
downloadlibxslt-c21fe206b08ec948a70edcd24ba5030d7634fab9.tar.gz
libxslt-c21fe206b08ec948a70edcd24ba5030d7634fab9.tar.bz2
libxslt-c21fe206b08ec948a70edcd24ba5030d7634fab9.zip
applied patch from Maurice van der Pot to fix EXSLT week-in-year extenson
* libexslt/date.c tests/exslt/date/datetime.1.out tests/exslt/date/date.1.out tests/exslt/date/date.1.xml: applied patch from Maurice van der Pot to fix EXSLT week-in-year extenson which was not conforming to the definition. This also changes the output of the tests a bit. Should fix #452876 Daniel svn path=/trunk/; revision=1446
Diffstat (limited to 'libexslt')
-rw-r--r--libexslt/date.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/libexslt/date.c b/libexslt/date.c
index 2325de33..1127e18a 100644
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -2129,7 +2129,7 @@ static double
exsltDateWeekInYear (const xmlChar *dateTime)
{
exsltDateValPtr dt;
- long fdiy, fdiw, ret;
+ long diy, diw, year, ret;
if (dateTime == NULL) {
#ifdef WITH_TIME
@@ -2147,20 +2147,26 @@ exsltDateWeekInYear (const xmlChar *dateTime)
}
}
- fdiy = DAY_IN_YEAR(1, 1, dt->value.date.year);
-
+ diy = DAY_IN_YEAR(dt->value.date.day, dt->value.date.mon,
+ dt->value.date.year);
+
/*
* Determine day-in-week (0=Sun, 1=Mon, etc.) then adjust so Monday
* is the first day-in-week
*/
- fdiw = (_exsltDateDayInWeek(fdiy, dt->value.date.year) + 6) % 7;
-
- ret = (DAY_IN_YEAR(dt->value.date.day, dt->value.date.mon,
- dt->value.date.year) + fdiw) / 7;
+ diw = (_exsltDateDayInWeek(diy, dt->value.date.year) + 6) % 7;
/* ISO 8601 adjustment, 3 is Thu */
- if (fdiw <= 3)
- ret += 1;
+ diy += (3 - diw);
+ if(diy < 1) {
+ year = dt->value.date.year - 1;
+ if(year == 0) year--;
+ diy = DAY_IN_YEAR(31, 12, year) + diy;
+ } else if (diy > DAY_IN_YEAR(31, 12, dt->value.date.year)) {
+ diy -= DAY_IN_YEAR(31, 12, dt->value.date.year);
+ }
+
+ ret = ((diy - 1) / 7) + 1;
exsltDateFreeDate(dt);