홍용민

남은 시간 예측 기능 model로 옮김

......@@ -64,6 +64,7 @@ for(var i=0; i<routeID.length; i++){
const GateBusUrl = bus_url + '?servicekey=' + process.env.key + '&stationId=' + gateStationID; //국제캠 정문 정류장
let date = new Date();
let predictTime = ['-1', '-1', '-1', '-1'];
let body = new Object();
function predict(){
console.log(GateBusUrl);
......@@ -95,6 +96,25 @@ function predict(){
Bus[index]["MaxPredictTime"] = predictHour2 + ":" + predictMinute2;
predictTime = [predictHour1 + "", predictMinute1 + "", predictHour2 + "", predictMinute2 + ""]
const dateBusDeparture = new Date(date.getFullYear(), date.getMonth(), date.getDate(), predictTime[0]*1, predictTime[1]*1, 0);
var gapSec = (dateBusDeparture.getTime() - date.getTime())/1000;
var gapHour = Math.floor(gapSec / 60 / 60);
var gapMin = Math.floor((gapSec - gapHour * 3600) / 60);
// var ans = gapHour + "시간" + gapMin + "분 이상";
// var ETD_min_H = predictTime[0];
// var ETD_min_M = predictTime[1];
// var ETD_max_H = predictTime[2];
// var ETD_max_M = predictTime[3];
body.remainTime = gapHour + "시간" + gapMin + "분 이상";
body.ETD_min_H = predictTime[0];
body.ETD_min_M = predictTime[1];
body.ETD_max_H = predictTime[2];
body.ETD_max_M = predictTime[3];
}
})
})
......