ClosestFacilityTask sends the timeOfDay parameter as a string of Date format instead of an epoch format to the server.

140
0
10-14-2019 12:56 PM
Stacy-Rendall
New Contributor III

I have discovered bug with the ArcGIS API for JavaScript, which affects ClosestFacility calls: “timeOfDay” values are incorrectly sent to the server as a string of the date, i.e. timeOfDay: “2019-08-19T23:45:00.000Z”, however testing using the endpoint reveals it should be sent in a milliseconds since epoch (Unix) format, i.e. timeOfDay: 1566258300000. This causes the server to resort to some kind of default time, so that the wrong result is returned… Route task (I have not tested others) does correctly send the routing time parameter (startTime) in Unix format.

To confirm the issue:

  1. specify a timeOfDay, timeOfDayUsage and travelDirection in Closest Facility Parameters
  2. open browser developer tools to Network tab
  3. send request, receive response
  4. review corresponding startTime/endTime in response - it will have defaulted to some time like 8AM today (seems to vary), which is not the requested time
  5. compare this behaviour to Routing requests (startTime parameter)

Here is a Codepen demonstrating the above: https://codepen.io/stacy-rendall/pen/qBWZQJr

For some unknown reason Esri have noted this bug, but closed the issue claiming that it is "by design" (BUG-000124691: ClosestFacilityTask sends the timeOfDay parameter as.. ), this makes no sense - the bug causes the server to ignore the specified "timeOfDay", there is no way that could be "by design".

I have implemented a pretty rough workaround (calling the server directly using "esri/request") that I can share if it is useful to anyone (Esri devs?).

0 Kudos
0 Replies