Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

Fix time validation (20:undefined), show end_time in place inspector

Mauriced0d39d1e35f1
diff --git a/client/src/components/Planner/DayPlanSidebar.jsx b/client/src/components/Planner/DayPlanSidebar.jsx
index cc671e84c..9c5d2ef30 100644
--- a/client/src/components/Planner/DayPlanSidebar.jsx
+++ b/client/src/components/Planner/DayPlanSidebar.jsx
@@ -23,7 +23,10 @@ function formatDate(dateStr, locale) {
function formatTime(timeStr, locale, timeFormat) {
if (!timeStr) return ''
try {
- const [h, m] = timeStr.split(':').map(Number)
+ const parts = timeStr.split(':')
+ const h = Number(parts[0]) || 0
+ const m = Number(parts[1]) || 0
+ if (isNaN(h)) return timeStr
if (timeFormat === '12h') {
const period = h >= 12 ? 'PM' : 'AM'
const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h
diff --git a/client/src/components/Planner/PlaceInspector.jsx b/client/src/components/Planner/PlaceInspector.jsx
index 4f2d64447..f5b312d3a 100644
--- a/client/src/components/Planner/PlaceInspector.jsx
+++ b/client/src/components/Planner/PlaceInspector.jsx
@@ -75,7 +75,10 @@ function convertHoursLine(line, timeFormat) {
function formatTime(timeStr, locale, timeFormat) {
if (!timeStr) return ''
try {
- const [h, m] = timeStr.split(':').map(Number)
+ const parts = timeStr.split(':')
+ const h = Number(parts[0]) || 0
+ const m = Number(parts[1]) || 0
+ if (isNaN(h)) return timeStr
if (timeFormat === '12h') {
const period = h >= 12 ? 'PM' : 'AM'
const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h
@@ -216,7 +219,7 @@ export default function PlaceInspector({
{place.place_time && (
<div style={{ display: 'flex', alignItems: 'center', gap: 4, marginTop: 3 }}>
<Clock size={10} color="var(--text-faint)" style={{ flexShrink: 0 }} />
- <span style={{ fontSize: 12, color: 'var(--text-muted)' }}>{formatTime(place.place_time, locale, timeFormat)}</span>
+ <span style={{ fontSize: 12, color: 'var(--text-muted)' }}>{formatTime(place.place_time, locale, timeFormat)}{place.end_time ? ` – ${formatTime(place.end_time, locale, timeFormat)}` : ''}</span>
</div>
)}
{place.lat && place.lng && (