brain[sic]
-----Original Message-----
From: Mark Robinson [mailto:mark.robinson@hk.tntfreight.com]
Sent: Friday, March 10, 2006 7:01 PM
To: xwiki-users@objectweb.org
Subject: Re: [xwiki-users] Dates (was: Long arithmetic...?)Typical. I missed a brace off the if statement.Sorry if you just cut and pasted the wrong answer.Cheers,Mark.CORRECTION BELOWHi Brian.I am not sure about with Velocity but you should be able to do this easily with a Groovy script.It basically is Java without the braces and type declarations so it is very powerful. Apologies if I have it wrong below but I have only started playing with it a few days ago.Try something like this below in your page.<%def today = new Date()println todayif(testitem < (today - 7)){println "This is more than a week old"}else{println "This is less than a week old"}%>If someone who knows Groovy well can correct that for you it might be a solution.Hope it helps.Cheers,Mark
On 11 Mar 2006, at 1:19 AM, THOMAS, BRIAN M ((SBCSI)) wrote:
It troubles me that no one has had an answer to this so far.I tried asking roughly the same question of the velocity-users list andwas told that a new version of Velocity now does arithmetic withnon-integer numbers, but two things make that problematic: first, Ihave limited access to the server to install software; second, I can'tbelieve that no one in all of XWiki's lifetime has ever tried to do anydate calculations, such as the difference of two dates, oradding/subtracting intervals.Isn't there an easier way to do this? All I want to do is decidewhether something's a week old.brain[sic]-----Original Message-----From: THOMAS, BRIAN M (SBCSI)Sent: Friday, March 03, 2006 5:18 PMSubject: [xwiki-users] Long arithmetic...?It seems that a Velocity #set directive fails when the RHS involves anyarithmetic operation with long integers.Specifically, I just wanted to determine the difference between twodates, thus:#set ($age = $xwiki.currentDate.time -$obj.xWikiObject.getDateValue("donedate").time)I confirmed that I got credible results from both of the operands byprinting them, and I could assign either of them to another variablename, but setting $age to the result of any arithmetic operation withany of them always gave "$age" as the formatted result.This shouldn't be this hard, should it?brain[sic]--You receive this message as a subscriber of the xwiki-users@objectweb.org mailing list.To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.orgFor general help: mailto:sympa@objectweb.org?subject=helpObjectWeb mailing lists service home page: http://www.objectweb.org/wws