Summary

Article ID:360033193031
1 minute readKnowledge base
On this page

Q: Current examples of email notifiers do not include the job’s elapsed time. Is it available?
A: Yes, it can be accessed as myJob.elapsedTime.

Q: But it is in milliseconds. How can I display it in a human-readable format?
A1: Find a reasonable date conversion function on the Internet.
A2: There is an example of such a function.

Solution

The following code snippet could cover this use case. This snippet can be found as part of the definition for the notifierTemplate property inside the procedure.

Examples

$[/javascript...    function quantify (number, noun)    {        if (number == 1) {            // Singular form, no need to add an "s".            return number + " " + noun;        }        return number + " " + noun + "s";    }    var seconds = Math.floor (myJob.elapsedTime / 1000);    var minutes = Math.floor (seconds / 60);    seconds %= 60;    var elapsedString = quantify(seconds, "second");    if (minutes > 0) {        var hours = Math.floor(minutes/60);        minutes %= 60;        elapsedString = quantify(minutes, "minute") + ", " + elapsedString;        if (hours > 0) {            elapsedString = quantify(hours, "hour") + ", " + elapsedString;        }    }...]