File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -505,6 +505,8 @@ async function openTripHistory() {
505505 </div>
506506 ` . trim ( ) ;
507507
508+ console . log ( tripHistory ) ;
509+
508510 // populate the trip list
509511 addTripsToDOM ( tripHistory ) ;
510512
@@ -555,8 +557,13 @@ function addTripsToDOM(tripHistory) {
555557 const formattedStartTime = tripDate . toLocaleTimeString ( "pt" ) ;
556558
557559 // Get formatted time
558- let tripTime = new Date ( Date . parse ( trip . endDate ) - Date . parse ( trip . startDate ) ) ;
559- const formattedTime = tripTime . getHours ( ) + "h" + tripTime . getMinutes ( ) . toString ( ) . padStart ( 2 , "0" ) + "m" ;
560+ const ms = Date . parse ( trip . endDate ) - Date . parse ( trip . startDate ) ;
561+ const formattedTime =
562+ ( ms >= 1000 * 60 * 60 ? Math . floor ( ms / ( 1000 * 60 * 60 ) ) + "h" : "" ) +
563+ ( Math . floor ( ms / ( 1000 * 60 ) ) % 60 ) +
564+ "m" +
565+ ( Math . floor ( ms / 1000 ) % 60 ) +
566+ "s" ;
560567
561568 // Get formatted cost
562569 let formattedCost = parseFloat ( trip . cost ) . toFixed ( 2 ) ;
You can’t perform that action at this time.
0 commit comments