Hi,
This script can calculate in minutes, how much time did it take to close an event.
I need to add to this script "skipweekend = Friday and saturday" and skip hours that are not work hours [ work hours = 8 – 17]
Can you please help me with this request?
Thanks a lot.
Best regards
Arige
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.core.util.DateUtils
import org.apache.log4j.Logger
import org.apache.log4j.Level
import java.text.SimpleDateFormat
import java.util.Date
import java.util.concurrent.TimeUnit
import java.lang.Object
//try
//{
//java.sql.Timestamp start
//java.sql.Timestamp end
def log = Logger.getLogger("com.ayalon.test2")
log.setLevel(Level.ERROR)
def start = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("האירוע החל ב"))
log.debug "Comment Author: " + start;
def end = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("אירוע הסתיים ב"))
log.debug "Comment Author: " + end;
if (start == null) return -1
if (end == null) return -1
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date startDate = formatter.parse(start.toString());
Date endDate = formatter.parse(end.toString());
log.debug "string of startDate" + startDate;
log.debug "string of endDate" + endDate;
long timepassed = (endDate.getTime() - startDate.getTime());
log.debug "Comment Author: " + timepassed;
long minutes = TimeUnit.MILLISECONDS.toMinutes(timepassed);
log.debug minutes
//def diff = (endDate.getTime() - startDate.getTime())/1000/60
//return startDate.getTime().doubleValue()
return minutes
//}catch(e){return 0}