Is thete any "week" custom field?

Hello people,

is there any week custom field available in JIRA, or some add-on for that?

I would like to have a field where I can select a calandar date (ie: Feb/19th/2014) and the field stores W7 value, or Week7.

Of course I can create a select list with W1 - w53, but users will be confusing.. because they need to convert their dates into week format manualy.

thanks

1 answer

1 accepted

Hi,

Nice question, This can be done,

How are we going to achieve ?

You will be having a datepicker custom field and you need to create a select list with W1 - w53, in datepicker customfield we are going to add a javascript, which will automatically select the week.

But You have to add javascript.Please check the below javascript.

These code which are below will come inside the date picker custom field .This is for getting the week

Date.prototype.getWeek = function () {

// Create a copy of this date object

var target = new Date(this.valueOf());

// ISO week date weeks start on monday

// so correct the day number

var dayNr = (this.getDay() + 6) % 7;

// ISO 8601 states that week 1 is the week

// with the first thursday of that year.

// Set the target date to the thursday in the target week

target.setDate(target.getDate() - dayNr + 3);

// Store the millisecond value of the target date

var firstThursday = target.valueOf();

// Set the target to the first thursday of the year

// First set the target to january first

target.setMonth(0, 1);

// Not a thursday? Correct the date to the next thursday

if (target.getDay() != 4) {

target.setMonth(0, 1 + ((4 - target.getDay()) + 7) % 7);

}

// The weeknumber is the number of weeks between the

// first thursday of the year and the thursday in the target week

return 1 + Math.ceil((firstThursday - target) / 604800000); // 604800000 = 7 * 24 * 3600 * 1000

}

This is for getting the week from datepicker customfield and setting it in the week customfield

$("#datecustomfield").change(function(){

var today = $("#datecustomfield").getDate();

var week = "W"+today.getWeek();

$("#weekcustomfield option[text="+week+"]").attr("selected","selected");

});

Hope this helps you!

Thank you Nitram. I did not test it yet, but I got the idea.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Wednesday in Jira

Join our webinar: How 1B+ feature flag events helped us build the new Jira

Every time you release software, there's a bit of risk – that there's a bug, that something breaks, or that the feature doesn't resonate with customers. Feature flagging helps make high stakes s...

130 views 0 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you