Skip to content

Commit 46998d5

Browse files
committed
Changed Date.parse() to new Date() (better practice!)
1 parent b8b3627 commit 46998d5

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

app/charts/route-trace.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ const RouteLocations = (props) => {
7272
for (let i = 0; i < tracePoints[position].length; i += 1) {
7373
if (i !== tracePoints[position].length - 1) {
7474
// Calc time difference (when not at the end of array):
75-
// Using Date.parse() because timeSent's value is a string.
76-
const timeDiff = Date.parse(tracePoints[position][i + 1].timeSent) - Date.parse(tracePoints[position][i].timeSent);
75+
// Convert time str to Date obj w/ new Date(), then get the time difference.
76+
const timeDiff = new Date(tracePoints[position][i + 1].timeSent) - new Date(tracePoints[position][i].timeSent);
7777
resArray.push(
7878
<div className="RouteCircle" key={i}>
7979
{/* Altering this <p> so it displays only microsvc_name */}
@@ -83,7 +83,6 @@ const RouteLocations = (props) => {
8383
{/* Adding another <p> that displays time difference btw curr obj and next obj */}
8484
<p id="routeTimeDiff">
8585
{/* Time: {tracePoints[position][i].timeSent} */}
86-
{/* What datatype? {Date.parse(tracePoints[position][i].timeSent) - Date.parse(tracePoints[position][i + 1].timeSent)} ms */}
8786
Time elapsed: {timeDiff} ms
8887
</p>
8988
</div>,

0 commit comments

Comments
 (0)