A useful feature of the RouteTask is the ability to constrain stop visits to certain times of day, or "time windows". If you were required to deliver orders to four homes and each customer was available during a limited time period during the day, the route task could help you find the most efficient path for making all the deliveries.
Time windows are treated as a "soft" constraint. This means that although the solver attempts to honor time windows, if necessary, it will violate the time windows of some stops in order to reach them. Remember also that the stops will be visited in the order they were added unless you set RouteParameters.findBestSequence to true.
You set time windows as attributes on the stops. Here's an example of three stops with time windows:
routeParams.UseTimeWindows = true;
stop1.Attributes = { "Name": "A",
"TimeWindowStart": "8:00 AM",
"TimeWindowEnd": "8:05 AM"};
stop2.Attributes = { "Name": "B",
"TimeWindowStart": "8:10 AM",
"TimeWindowEnd": "8:15 AM"};
stop3.Attributes = { "Name": "C",
"TimeWindowStart": "8:20 AM",
"TimeWindowEnd": "8:25 AM"};
If by necessity the route arrives at a stop after the time window has expired, the violation time is noted. Similarly, if a route arrives at a stop before the time window begins, the wait time is noted. You can retrieve violation and wait times as attributes of a stop or route. Here's how you might report these values:
document.getElementById("itCumul_Time").value = stop1.Attributes["Cumul_Time"];
document.getElementById("itWait_Time").value = stop1.Attributes["Wait_Time"];
document.getElementById("itCumulWait_Time").value = stop1.Attributes["CumulWait_Time"];
document.getElementById("itViolation_Time").value = stop1.Attributes["Violation_Time"];
document.getElementById("itCumulViolation_Time").value = stop1.Attributes["CumulViolation_Time"];
For a more detailed example of how time windows work, see Routing with time windows in the ArcGIS Desktop Help.