如何在Enterprise Architect的JScript中比较日期对象?

时间:2013-02-04 12:17:47

标签: javascript vbscript jscript enterprise-architect

我制作了jscript,它运行了包中的元素,现在我需要添加element.created与今天的比较。我该怎么做?

1 个答案:

答案 0 :(得分:0)

请参阅以下代码并相应修改

// get the date from the element
var dateCreated = new Date(theElement.Created);

// remove the hours, minutes, seconds, miliseconds
dateCreated.setHours(0,0,0,0);

// create the date object to compare
// input parameter is yyyy, mm, dd
// please note that the mm starts from 0 for January
var dateToCompare = new Date(2013, 0, 13);

// sample usage
if (dateCreated > dateToCompare)
{
    Session.Output("Creation date is newer");
}
else if (dateCreated < dateToCompare)
{
    Session.Output("Creation date is older");
}
else
{
    Session.Output("Creation date match");
}