Skip to content

Commit

Permalink
Update eta.js - Time to go added and null value corrected (#127)
Browse files Browse the repository at this point in the history
in this PR:

1.  'navigation.courseGreatCircle.nextPoint.timeToGo' added
       a.  this is in Seconds per the spec.
       b.  the null value set to null vs "--"
2.  eta null value set to null vs "--"
  • Loading branch information
Techstyleuk authored Jan 4, 2024
1 parent 1585fdc commit 5110d32
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions calcs/eta.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,32 @@ module.exports = function (app) {
date = new Date()
}

var datems = date.getTime()
var timetopoint = Math.floor(
distance / (velocityMadeGood * 0.514444) * 1000
)
var datems = date.getTime()
var timetopoint = Math.floor(distance / (velocityMadeGood * 0.514444) * 1000)

// app.debug(`Using datetime: ${date} ms to point : ${timetopoint} currentms: ${datems}`)
var etams = datems + timetopoint
// app.debug(`eta in ms: ${etams} ms to point : ${timetopoint} currentms: ${datems}`)
// app.debug(`Using datetime: ${date} ms to point : ${timetopoint} currentms: ${datems}`)
var etams = datems + timetopoint
// app.debug(`eta in ms: ${etams} ms to point : ${timetopoint} currentms: ${datems}`)

if (velocityMadeGood > 0) {
var etad = new Date(parseInt(etams))
var eta = etad.toISOString()
var ttg = Math.floor((timetopoint / 1000));
} else {
var eta = '--'
var eta = null
var ttg = null
}
app.debug(`what is eta: ${eta} etams: ${etams} etad: ${etad}`)
// app.debug(`what is eta: ${eta} etams: ${etams} etad: ${etad}`)

return [
{
path: 'navigation.courseGreatCircle.nextPoint.estimatedTimeOfArrival',
value: eta
path: 'navigation.courseGreatCircle.nextPoint.estimatedTimeOfArrival', value: eta
},
{
path: 'navigation.courseGreatCircle.nextPoint.eta',
value: eta
path: 'navigation.courseGreatCircle.nextPoint.timeToGo', value: ttg
},
{
path: 'navigation.courseGreatCircle.nextPoint.eta', value: eta
}
]
}
Expand Down

0 comments on commit 5110d32

Please sign in to comment.