|
4 | 4 | --> |
5 | 5 |
|
6 | 6 | <script setup lang="ts"> |
7 | | -import moment from '@nextcloud/moment' |
8 | 7 | import { computed } from 'vue' |
| 8 | +import { DateTime } from 'luxon' |
9 | 9 | import { CalendarEvent } from '../../components/Calendar/CalendarPeek.vue' |
10 | 10 |
|
11 | 11 | import type { Option } from '../../stores/options.types' |
@@ -37,31 +37,29 @@ const fontColor = computed(() => { |
37 | 37 | return l > 0.5 ? '#222' : '#ddd' |
38 | 38 | }) |
39 | 39 |
|
40 | | -const dayStart = computed(() => moment.unix(calendarEvent.start).format('ddd')) |
41 | | -
|
42 | | -const dayEnd = computed(() => moment.unix(calendarEvent.end - 1).format('ddd')) |
| 40 | +const eventStart = computed(() => DateTime.fromSeconds(calendarEvent.start)) |
| 41 | +const eventEnd = computed(() => DateTime.fromSeconds(calendarEvent.end)) |
43 | 42 |
|
44 | 43 | const dayDisplay = computed(() => { |
45 | | - if (dayEnd.value === dayStart.value) { |
46 | | - return dayStart.value |
| 44 | + if (eventEnd.value.hasSame(eventStart.value.minus({ second: 1 }), 'day')) { |
| 45 | + return eventStart.value.toLocaleString({ weekday: 'short' }) |
47 | 46 | } |
48 | 47 |
|
49 | | - return `${dayStart.value} - ${dayEnd.value}` |
| 48 | + return `${eventStart.value.toLocaleString({ weekday: 'short' })} - ${eventEnd.value.toLocaleString({ weekday: 'short' })}` |
50 | 49 | }) |
51 | 50 |
|
52 | | -const timeStart = computed(() => moment.unix(calendarEvent.start).format('LT')) |
53 | | -
|
54 | | -const timeEnd = computed(() => moment.unix(calendarEvent.end).format('LT')) |
55 | | -
|
56 | 51 | const timeDisplay = computed(() => { |
57 | | - if (timeEnd.value === timeStart.value) { |
58 | | - return timeStart.value |
| 52 | + if (eventStart.value.hasSame(eventEnd.value, 'minute')) { |
| 53 | + return eventStart.value.toLocaleString(DateTime.TIME_SIMPLE) |
59 | 54 | } |
60 | | - return `${timeStart.value} - ${timeEnd.value}` |
| 55 | +
|
| 56 | + return `${eventStart.value.toLocaleString(DateTime.TIME_SIMPLE)} - ${eventEnd.value.toLocaleString(DateTime.TIME_SIMPLE)}` |
61 | 57 | }) |
62 | 58 |
|
63 | 59 | const showJustDays = computed( |
64 | | - () => dayStart.value !== dayEnd.value || calendarEvent.allDay, |
| 60 | + () => |
| 61 | + !eventEnd.value.hasSame(eventStart.value.minus({ second: 1 }), 'day') |
| 62 | + || calendarEvent.allDay, |
65 | 63 | ) |
66 | 64 |
|
67 | 65 | const statusClass = computed(() => calendarEvent.status.toLowerCase()) |
|
0 commit comments