@@ -28,7 +28,7 @@ import { useIsInCall } from '../../composables/useIsInCall.js'
28
28
import { useStore } from ' ../../composables/useStore.js'
29
29
import { CONVERSATION } from ' ../../constants.ts'
30
30
import type { DashboardEventRoom } from ' ../../types/index.ts'
31
- import { formattedTime } from ' ../../utils/formattedTime.ts'
31
+ import { formattedTime , ONE_DAY_IN_MS } from ' ../../utils/formattedTime.ts'
32
32
33
33
const props = defineProps <{
34
34
eventRoom: DashboardEventRoom ,
@@ -57,20 +57,45 @@ const eventDateLabel = computed(() => {
57
57
}
58
58
const startDate = new Date (props .eventRoom .start * 1000 )
59
59
const endDate = new Date (props .eventRoom .end * 1000 )
60
- const startDateString = startDate .toLocaleString (getCanonicalLocale (), { hour: ' 2-digit' , minute: ' 2-digit' })
61
- const endDateString = endDate .toLocaleString (getCanonicalLocale (), { hour: ' 2-digit' , minute: ' 2-digit' })
62
- const dateString = isToday .value
63
- ? t (' spreed' , ' Today' )
64
- : moment (startDate ).calendar (null , {
65
- nextDay: ' [Tomorrow]' ,
66
- nextWeek: ' dddd' ,
67
- sameElse: ' dddd'
68
- })
69
- return t (' spreed' , ' {dateString} {startDateString} - {endDateString}' , {
70
- dateString ,
71
- startDateString ,
72
- endDateString ,
73
- })
60
+ const isToday = startDate .toDateString () === new Date ().toDateString ()
61
+ const isTomorrow = startDate .toDateString () === new Date (Date .now () + ONE_DAY_IN_MS ).toDateString ()
62
+
63
+ let time
64
+ if (startDate .toDateString () === endDate .toDateString ()) {
65
+ if (isToday || isTomorrow ) {
66
+ // show the time only
67
+ const timeRange = Intl .DateTimeFormat (getCanonicalLocale (), {
68
+ hour: ' numeric' ,
69
+ minute: ' numeric' ,
70
+ }).formatRange (startDate , endDate )
71
+
72
+ const relativeFormatter = new Intl .RelativeTimeFormat (' en' , { numeric: ' auto' })
73
+
74
+ // TRANSLATORS: e.g. "Tomorrow 10:00 - 11:00"
75
+ time = t (' spreed' , ' {dayPrefix} {dateTime}' , {
76
+ dayPrefix: isToday ? relativeFormatter .format (0 , ' day' ) : relativeFormatter .format (1 , ' day' ),
77
+ dateTime: timeRange
78
+ })
79
+ } else {
80
+ time = Intl .DateTimeFormat (getCanonicalLocale (), {
81
+ weekday: ' long' ,
82
+ hour: ' numeric' ,
83
+ minute: ' numeric' ,
84
+ }).formatRange (startDate , endDate )
85
+ }
86
+ } else {
87
+ // show the month and the year as well
88
+ time = Intl .DateTimeFormat (getCanonicalLocale (), {
89
+ month: ' long' ,
90
+ year: ' numeric' ,
91
+ day: ' 2-digit' ,
92
+ hour: ' numeric' ,
93
+ minute: ' numeric' ,
94
+ }).formatRange (startDate , endDate )
95
+
96
+ }
97
+
98
+ return time
74
99
})
75
100
76
101
const hasAttachments = computed (() => {
@@ -120,7 +145,7 @@ function handleJoin({ call = false } = {}) {
120
145
</span >
121
146
</h4 >
122
147
<p class =" event-card__date secondary_text" >
123
- {{ eventDateLabel }}
148
+ < span > {{ eventDateLabel }}</ span >
124
149
<template v-if =" hasCall " >
125
150
<IconVideo :size =" 20" :fill-color =" '#E9322D'" />
126
151
<span >{{ elapsedTime }}</span >
@@ -215,6 +240,10 @@ function handleJoin({ call = false } = {}) {
215
240
display : flex ;
216
241
gap : 2px ;
217
242
243
+ & > span ::first-letter {
244
+ text-transform : capitalize ;
245
+ }
246
+
218
247
& > * {
219
248
white-space : nowrap ;
220
249
overflow : hidden ;
@@ -291,8 +320,6 @@ function handleJoin({ call = false } = {}) {
291
320
white-space : nowrap ;
292
321
overflow : hidden ;
293
322
text-overflow : ellipsis ;
294
- font-size : inherit ;
295
- margin : 0 ;
296
323
}
297
324
}
298
325
0 commit comments