Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Showing First Day Of A Week

Anna Rumawas July 8, 2013

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

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Matthew J. Horn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 8, 2013

I think you'll want to find a JavaScript library that performs these kinds of functions, and include that in your Confluence page.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2013

I've used date.js and it's pretty neat! - http://www.datejs.com/

0 votes
Anna Rumawas July 14, 2013

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>

TAGS
AUG Leaders

Atlassian Community Events