Defect age script
Hi all,
I have a dojo script which helps to display the Defect age,
Till today afternoon its worked fine, but suddenly it is displaying defect age is 3d old for a defects created after 1PM.
Request your help and suggestion..
Thank You...!
dojo.provide("example.calculated.defectAgeValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var fromISOString = dojo.date.stamp.fromISOString;
dojo.declare("example.calculated.defectAgeValueProvider", null, {
getValue: function(attribute, workItem, configuration) {
var creationDate = fromISOString(workItem.getValue(WorkItemAttributes.CREATION_DATE));
if (creationDate) {
var ageInSeconds = (Date.now() - creationDate.getTime()) / 1000;
var days = parseInt(ageInSeconds / 86400);
var hours = parseInt((ageInSeconds-days * 86400) / 3600);
var minutes = parseInt((ageInSeconds-days * 86400 - hours * 3600) / 60);
return days + " d ";
}
return " ";
}
});
})();
I have a dojo script which helps to display the Defect age,
Till today afternoon its worked fine, but suddenly it is displaying defect age is 3d old for a defects created after 1PM.
Request your help and suggestion..
Thank You...!
dojo.provide("example.calculated.defectAgeValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
dojo.require("dojo.date.stamp");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
var fromISOString = dojo.date.stamp.fromISOString;
dojo.declare("example.calculated.defectAgeValueProvider", null, {
getValue: function(attribute, workItem, configuration) {
var creationDate = fromISOString(workItem.getValue(WorkItemAttributes.CREATION_DATE));
if (creationDate) {
var ageInSeconds = (Date.now() - creationDate.getTime()) / 1000;
var days = parseInt(ageInSeconds / 86400);
var hours = parseInt((ageInSeconds-days * 86400) / 3600);
var minutes = parseInt((ageInSeconds-days * 86400 - hours * 3600) / 60);
return days + " d ";
}
return " ";
}
});
})();
One answer
This has worked for me in a different context
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); // To access the work item attributes dojo.require("dojo.date"); // We need the date class from Dojo to compare two dates dojo.require("dojo.date.stamp"); // We need the stamp class to work with ISO date strings . . . var beginDate = dojo.date.stamp.fromISOString(workItem.getValue("WorkItemAttributes.CREATION_DATE")); // Compare the two dates returns negative value due to order var compare = (dojo.date.difference(Date.now(), beginDate, "day")); return compare + " d ";