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

This commit is contained in:
Maurice
2026-03-24 21:44:30 +01:00
parent e70cd5729e
commit d0d39d1e35
2 changed files with 9 additions and 3 deletions

View File

@@ -23,7 +23,10 @@ function formatDate(dateStr, locale) {
function formatTime(timeStr, locale, timeFormat) { function formatTime(timeStr, locale, timeFormat) {
if (!timeStr) return '' if (!timeStr) return ''
try { 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') { if (timeFormat === '12h') {
const period = h >= 12 ? 'PM' : 'AM' const period = h >= 12 ? 'PM' : 'AM'
const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h

View File

@@ -75,7 +75,10 @@ function convertHoursLine(line, timeFormat) {
function formatTime(timeStr, locale, timeFormat) { function formatTime(timeStr, locale, timeFormat) {
if (!timeStr) return '' if (!timeStr) return ''
try { 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') { if (timeFormat === '12h') {
const period = h >= 12 ? 'PM' : 'AM' const period = h >= 12 ? 'PM' : 'AM'
const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h const h12 = h === 0 ? 12 : h > 12 ? h - 12 : h
@@ -216,7 +219,7 @@ export default function PlaceInspector({
{place.place_time && ( {place.place_time && (
<div style={{ display: 'flex', alignItems: 'center', gap: 4, marginTop: 3 }}> <div style={{ display: 'flex', alignItems: 'center', gap: 4, marginTop: 3 }}>
<Clock size={10} color="var(--text-faint)" style={{ flexShrink: 0 }} /> <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> </div>
)} )}
{place.lat && place.lng && ( {place.lat && place.lng && (