Add: DateTime handling when displaying delay

This commit is contained in:
williameriksson126 2020-12-10 12:32:40 +01:00
parent cf977ccb1f
commit cd2a61947f
5 changed files with 35 additions and 19 deletions

5
package-lock.json generated
View File

@ -10111,6 +10111,11 @@
"minimist": "^1.2.5"
}
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -7,6 +7,7 @@
"@testing-library/react": "^11.1.2",
"@testing-library/user-event": "^12.2.2",
"axios": "^0.21.0",
"moment": "^2.29.1",
"react": "^17.0.1",
"react-axios": "^2.0.3",
"react-dom": "^17.0.1",

View File

@ -27,25 +27,25 @@
}
},
{
"name": "Buss 123",
"sname": "123",
"journeyNumber": "24",
"name": "Buss 920",
"sname": "920",
"journeyNumber": "2",
"type": "BUS",
"stopid": "9022014014754002",
"stop": "Bollestadsvägen, Kungälv",
"time": "10:20",
"time": "12:26",
"date": "2020-12-10",
"journeyid": "9015014621000024",
"direction": "Ingenstans",
"journeyid": "9015014692000002",
"direction": "Bredsten",
"track": "B",
"rtTime": "10:11",
"rtTime": "12:26",
"rtDate": "2020-12-10",
"fgColor": "#006C93",
"bgColor": "#FFFFFF",
"stroke": "Solid",
"accessibility": "wheelChair",
"JourneyDetailRef": {
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=347217%2F124275%2F19874%2F105802%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26"
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=210630%2F70533%2F834318%2F346949%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26"
}
}
]

View File

@ -27,25 +27,25 @@
}
},
{
"name": "Buss 123",
"sname": "123",
"journeyNumber": "24",
"name": "Buss 920",
"sname": "920",
"journeyNumber": "2",
"type": "BUS",
"stopid": "9022014014754002",
"stop": "Bollestadsvägen, Kungälv",
"time": "10:20",
"time": "12:28",
"date": "2020-12-10",
"journeyid": "9015014621000024",
"direction": "Ingenstans",
"journeyid": "9015014692000002",
"direction": "Bredsten",
"track": "B",
"rtTime": "10:11",
"rtTime": "12:26",
"rtDate": "2020-12-10",
"fgColor": "#006C93",
"bgColor": "#FFFFFF",
"stroke": "Solid",
"accessibility": "wheelChair",
"JourneyDetailRef": {
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=347217%2F124275%2F19874%2F105802%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26"
"ref": "https://api.vasttrafik.se/bin/rest.exe/v2/journeyDetail?ref=210630%2F70533%2F834318%2F346949%2F80%3Fdate%3D2020-12-10%26station_evaId%3D14754002%26station_type%3Ddep%26format%3Djson%26"
}
}
]

View File

@ -9,6 +9,7 @@ import Button from './Button.js';
import disruptIcon from '../img/flash.svg';
import globalData from '../GlobalData.js'
import moment from "moment";
class DisruptionButton extends Button {
state = {
@ -20,13 +21,20 @@ class DisruptionButton extends Button {
globalData.currentPage.forceUpdate();
}
showMomentTime = (time) => {
//return(time.hours().toString()+ ":"+time.minutes().toString())
return(time.format("HH:mm"))
}
genDisrupt = () => {
this.state.disruption = undefined
if(this.state.jsonLocation === "ex1"){
for (let stopPoint of ex1.affectedStopPoints) {
if(stopPoint.gid === globData.user.stoppointgid){
this.state.disruption = ex1;
globData.stop.departures[0].newTime = ex1.time;
var old1t = moment(globData.stop.departures[0].time,"HH:mm");
old1t.add(ex1.time, "HH:mm");
globData.stop.departures[0].newTime = this.showMomentTime(old1t);
globData.stop.departures[0].trafficInfo = ex1.title;
}
}
@ -34,7 +42,9 @@ class DisruptionButton extends Button {
for (let stopPoint of ex2.affectedStopPoints) {
if(stopPoint.gid === globData.user.stoppointgid){
this.state.disruption = ex2;
globData.stop.departures[0].newTime = ex2.time;
var old2t = moment(globData.stop.departures[0].time,"HH:mm");
old2t.add(ex2.time, "HH:mm");
globData.stop.departures[0].newTime = this.showMomentTime(old2t);
globData.stop.departures[0].trafficInfo = ex2.title;
}
}