aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/app/components/SchedulesTable.tsx9
-rw-r--r--src/frontend/app/routes/estimates-$id.tsx4
-rw-r--r--src/frontend/app/routes/timetable-$id.tsx13
3 files changed, 20 insertions, 6 deletions
diff --git a/src/frontend/app/components/SchedulesTable.tsx b/src/frontend/app/components/SchedulesTable.tsx
index 60e7ab0..5df01e5 100644
--- a/src/frontend/app/components/SchedulesTable.tsx
+++ b/src/frontend/app/components/SchedulesTable.tsx
@@ -95,6 +95,13 @@ const timeToMinutes = (time: string): number => {
return hours * 60 + minutes;
};
+// Utility function to format GTFS time for display (handle hours >= 24)
+const formatTimeForDisplay = (time: string): string => {
+ const [hours, minutes] = time.split(":").map(Number);
+ const normalizedHours = hours % 24;
+ return `${normalizedHours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
+};
+
// Utility function to find nearby entries
const findNearbyEntries = (
entries: ScheduledTable[],
@@ -178,7 +185,7 @@ export const SchedulesTable: React.FC<TimetableTableProps> = ({
<div className="time-info">
<span className="departure-time">
- {entry.calling_time.slice(0, 5)}
+ {formatTimeForDisplay(entry.calling_time)}
</span>
</div>
</div>
diff --git a/src/frontend/app/routes/estimates-$id.tsx b/src/frontend/app/routes/estimates-$id.tsx
index e4006ef..74f24e6 100644
--- a/src/frontend/app/routes/estimates-$id.tsx
+++ b/src/frontend/app/routes/estimates-$id.tsx
@@ -65,9 +65,9 @@ const loadTimetableData = async (
throw new Error("Timetable not available for this region");
}
- const today = new Date().toISOString().split("T")[0]; // YYYY-MM-DD format
+ // Use "today" to let server determine date based on Europe/Madrid timezone
const resp = await fetch(
- `${regionConfig.timetableEndpoint}?date=${today}&stopId=${stopId}`,
+ `${regionConfig.timetableEndpoint}?date=today&stopId=${stopId}`,
{
headers: {
Accept: "application/json",
diff --git a/src/frontend/app/routes/timetable-$id.tsx b/src/frontend/app/routes/timetable-$id.tsx
index af5e42a..8a1cba7 100644
--- a/src/frontend/app/routes/timetable-$id.tsx
+++ b/src/frontend/app/routes/timetable-$id.tsx
@@ -38,9 +38,9 @@ const loadTimetableData = async (
// Add delay to see skeletons in action (remove in production)
await new Promise((resolve) => setTimeout(resolve, 1000));
- const today = new Date().toISOString().split("T")[0]; // YYYY-MM-DD format
+ // Use "today" to let server determine date based on Europe/Madrid timezone
const resp = await fetch(
- `${regionConfig.timetableEndpoint}?date=${today}&stopId=${stopId}`,
+ `${regionConfig.timetableEndpoint}?date=today&stopId=${stopId}`,
{
headers: {
Accept: "application/json",
@@ -61,6 +61,13 @@ const timeToMinutes = (time: string): number => {
return hours * 60 + minutes;
};
+// Utility function to format GTFS time for display (handle hours >= 24)
+const formatTimeForDisplay = (time: string): string => {
+ const [hours, minutes] = time.split(":").map(Number);
+ const normalizedHours = hours % 24;
+ return `${normalizedHours.toString().padStart(2, "0")}:${minutes.toString().padStart(2, "0")}`;
+};
+
// Filter past entries (keep only a few recent past ones)
const filterTimetableData = (
data: ScheduledTable[],
@@ -402,7 +409,7 @@ const TimetableTableWithScroll: React.FC<{
<div className="time-info">
<span className="departure-time">
- {entry.calling_time.slice(0, 5)}
+ {formatTimeForDisplay(entry.calling_time)}
</span>
<div className="service-id">
{parseServiceId(entry.service_id)}