時刻を4時で日付変更線として設定

This commit is contained in:
harukin-expo-dev-env
2025-09-08 15:12:22 +00:00
parent 4dba21ccdd
commit b43604c7f1

View File

@@ -51,13 +51,29 @@ export const FixedStation = ({ stationID }) => {
} else if (station[0].Station_JP == PrePos) {
return false;
}
const date = dayjs();
let [h, m] = d.time.split(":");
let delay = isNaN(currentTrain.filter((t) => t.num == d.train)[0].delay)
? 0
: currentTrain.filter((t) => t.num == d.train)[0].delay;
const db = date.hour(parseInt(h)).minute(parseInt(m) + parseInt(delay));
return !date.isAfter(db);
const date = dayjs();
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 = {
@@ -168,7 +184,6 @@ export const FixedStation = ({ stationID }) => {
setSelectedTrain(data);
}, [trainTimeAndNumber, currentTrain /*finalSwitch*/]);
console.log(selectedTrain);
return (
<TouchableOpacity
style={{ flex: 1, flexDirection: "row" }}
@@ -255,7 +270,9 @@ export const FixedStation = ({ stationID }) => {
))
) : (
<View style={{ backgroundColor: "white", flex: 1 }}>
<Text style={{ fontSize: 20 }}></Text>
<Text style={{ fontSize: 20 }}>
</Text>
</View>
)}
</View>
@@ -278,7 +295,7 @@ const FixedStationBoxEachTrain = ({ d, station }) => {
return (
<View
style={{ backgroundColor: "white", flexDirection: "row"}}
style={{ backgroundColor: "white", flexDirection: "row" }}
key={d.train + "-fixedStationBox"}
>
<Text style={{ fontSize: 20, flex: 1 }}>{d.time}</Text>