Excluding saturdays and sundays in scriptrunner for JIRA

Prashant Hiremath October 8, 2018

Hello All,

User inputs  Start Date and No. of Days. Based on Start Date and No. of Days, End Date should be automatically displayed.

Field Types used:

Start Date (Date/Time Picker)

No. of Days(Numeric Type)

End Date(Date/Time Picker)

We are using Scriptrunner for JIRA. The script works fine and outputs End date correctly. Addition to this script, I am not able to exclude Saturday and Sunday.

Kindly suggest the changes to be implemented to ensure, the script excludes Saturday and Sunday and displays the End Date.

 

Kind Regards,

Prashant

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

Issue issue = issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
//Custom field defined for No of days
def daysToAddCF = customFieldManager.getCustomFieldObjectByName("QK Number of Days")
//custome field for defining Start Date
def dateACF = customFieldManager.getCustomFieldObjectByName("QK Start Date")

def dateAValue = issue.getCustomFieldValue(dateACF) as Date
def daysToAdd = issue.getCustomFieldValue(daysToAddCF) as int
def dateB = Calendar.getInstance()

dateB.setTime(dateAValue)
dateB.add(Calendar.DATE,daysToAdd)
return dateB.getTime()

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events