diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2008-04-08 17:05:41 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2008-04-08 17:05:41 +0000 |
commit | 6f9f02c608d7a2b1398ca38e0c7e2f86fd70f543 (patch) | |
tree | aaafad161c1b4835eef162eb74c8da52cba98e20 | |
parent | f52a259fd7b71c6db120efd0a459f8d9310d5ef3 (diff) | |
download | libxslt-6f9f02c608d7a2b1398ca38e0c7e2f86fd70f543.tar.gz libxslt-6f9f02c608d7a2b1398ca38e0c7e2f86fd70f543.tar.bz2 libxslt-6f9f02c608d7a2b1398ca38e0c7e2f86fd70f543.zip |
add back #452876 patch lost on previous commit, Daniel
svn path=/trunk/; revision=1466
-rw-r--r-- | libexslt/date.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/libexslt/date.c b/libexslt/date.c index 2276778d..fef60443 100644 --- a/libexslt/date.c +++ b/libexslt/date.c @@ -2143,7 +2143,7 @@ static double exsltDateWeekInYear (const xmlChar *dateTime) { exsltDateValPtr dt; - long fdiy, fdiw, ret; + long diy, diw, year, ret; if (dateTime == NULL) { #ifdef WITH_TIME @@ -2161,20 +2161,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); |