時刻を4時で日付変更線として設定
This commit is contained in:
@@ -51,13 +51,29 @@ export const FixedStation = ({ stationID }) => {
|
|||||||
} else if (station[0].Station_JP == PrePos) {
|
} else if (station[0].Station_JP == PrePos) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const date = dayjs();
|
|
||||||
let [h, m] = d.time.split(":");
|
let [h, m] = d.time.split(":");
|
||||||
let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay)
|
let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay)
|
||||||
? 0
|
? 0
|
||||||
: currentTrain.filter((t) => t.num == d.train)[0].delay;
|
: currentTrain.filter((t) => t.num == d.train)[0].delay;
|
||||||
const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay));
|
const date = dayjs();
|
||||||
return !date.isAfter(db);
|
let targetHour = parseInt(h);
|
||||||
|
|
||||||
|
// 4時を日付変更線として処理
|
||||||
|
if (targetHour < 4) {
|
||||||
|
targetHour += 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentHour = date.hour();
|
||||||
|
if (currentHour < 4) {
|
||||||
|
currentHour += 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = dayjs()
|
||||||
|
.hour(targetHour)
|
||||||
|
.minute(parseInt(m) + parseInt(delay));
|
||||||
|
const currentTime = dayjs().hour(currentHour);
|
||||||
|
|
||||||
|
return !currentTime.isAfter(db);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
type trainDataProps = {
|
type trainDataProps = {
|
||||||
@@ -168,7 +184,6 @@ export const FixedStation = ({ stationID }) => {
|
|||||||
setSelectedTrain(data);
|
setSelectedTrain(data);
|
||||||
}, [trainTimeAndNumber, currentTrain /*finalSwitch*/]);
|
}, [trainTimeAndNumber, currentTrain /*finalSwitch*/]);
|
||||||
|
|
||||||
console.log(selectedTrain);
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{ flex: 1, flexDirection: "row" }}
|
style={{ flex: 1, flexDirection: "row" }}
|
||||||
@@ -255,7 +270,9 @@ export const FixedStation = ({ stationID }) => {
|
|||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<View style={{ backgroundColor: "white", flex: 1 }}>
|
<View style={{ backgroundColor: "white", flex: 1 }}>
|
||||||
<Text style={{ fontSize: 20 }}>当駅を発着する走行中の列車はありません。</Text>
|
<Text style={{ fontSize: 20 }}>
|
||||||
|
当駅を発着する走行中の列車はありません。
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
@@ -278,7 +295,7 @@ const FixedStationBoxEachTrain = ({ d, station }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{ backgroundColor: "white", flexDirection: "row"}}
|
style={{ backgroundColor: "white", flexDirection: "row" }}
|
||||||
key={d.train + "-fixedStationBox"}
|
key={d.train + "-fixedStationBox"}
|
||||||
>
|
>
|
||||||
<Text style={{ fontSize: 20, flex: 1 }}>{d.time}</Text>
|
<Text style={{ fontSize: 20, flex: 1 }}>{d.time}</Text>
|
||||||
|
Reference in New Issue
Block a user