Hi experts...
need a little help here.
I need a set of macros which provide some date arithmetics
For example, today is 9 July 2013
What i need is a user macro that when I type {start of week} and give param:
1. Monday and 1, result will be 8 July 2013
or Sunday and 1, result will be 7 July 2013
2. Monday and 7, result will be 14 July 2013 (which is 8 + 7days)
3. Monday and -1, result will be 7 July 2013 (which is 8 + (-1)day)
Can anyone help me?
Thanks in advance
Community moderators have prevented the ability to post new answers.
I think you'll want to find a JavaScript library that performs these kinds of functions, and include that in your Confluence page.
I've used date.js and it's pretty neat! - http://www.datejs.com/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks for the idea.
i finally managed using javascript:
## Macro title: Monday Friday plus Variable ## Macro has a body: N ## Output: Monday Friday plus Variable dates ## ## Developed by: Anna ## Date created: 12/07/2013 ## Installed by: Anna ## @param DayVariable:title=DayVariable|type=string|required=true|desc=Number of days you want to add <script type="text/javascript"> var objToday = new Date(); document.write('Today: ' + objToday); document.write('<br>'); document.write('Monday + (' + $paramDayVariable + '): ' + getMonday(objToday)); document.write('<br>'); document.write('Friday + (' + $paramDayVariable + '): ' + getFriday(objToday)); function getMonday(d) { d = new Date(d); var day = d.getDay(), diff = d.getDate() - day + (day == 0 ? -6:1) + $paramDayVariable; return new Date(d.setDate(diff)); } function getFriday(d) { d = new Date(d); var day = d.getDay(), diff = d.getDate() - day + (day == 0 ? -6:5) + $paramDayVariable; return new Date(d.setDate(diff)); } </script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.