diff --git a/frontend/src/components/ScheduleBlock.vue b/frontend/src/components/ScheduleBlock.vue index 3f9b369..b02a316 100644 --- a/frontend/src/components/ScheduleBlock.vue +++ b/frontend/src/components/ScheduleBlock.vue @@ -14,7 +14,7 @@ - {{ block.label }}
- {{ block.time_start }} – {{ block.time_end }} + {{ formatTime(block.time_start) }} – {{ formatTime(block.time_end) }} · {{ durationLabel }} @@ -35,6 +35,14 @@ const props = defineProps({ compact: { type: Boolean, default: false }, }) +function formatTime(str) { + if (!str) return '' + const [h, m] = str.split(':').map(Number) + const period = h >= 12 ? 'PM' : 'AM' + const hour = h % 12 || 12 + return `${hour}:${String(m).padStart(2, '0')} ${period}` +} + const subjectColor = computed(() => props.block.subject?.color || '#475569') const subjectName = computed(() => props.block.subject?.name || null) diff --git a/frontend/src/views/AdminView.vue b/frontend/src/views/AdminView.vue index 99eff44..cfe2661 100644 --- a/frontend/src/views/AdminView.vue +++ b/frontend/src/views/AdminView.vue @@ -212,7 +212,7 @@
- {{ block.time_start }} – {{ block.time_end }} + {{ formatTime(block.time_start) }} – {{ formatTime(block.time_end) }} {{ block.label || subjectName(block.subject_id) || 'Unnamed' }} {{ blockDurationLabel(block) }} @@ -384,6 +384,14 @@ function subjectName(id) { return subjects.value.find((s) => s.id === id)?.name || null } +function formatTime(str) { + if (!str) return '' + const [h, m] = str.split(':').map(Number) + const period = h >= 12 ? 'PM' : 'AM' + const hour = h % 12 || 12 + return `${hour}:${String(m).padStart(2, '0')} ${period}` +} + function sortedBlocks(blocks) { const toMin = (t) => { if (!t) return 0; const [h, m] = t.split(':').map(Number); return h * 60 + m } return (blocks || []).slice().sort((a, b) => toMin(a.time_start) - toMin(b.time_start))