Display time in timezone configured on the account
Use the timezone configured on the account, or the default timezone if no timezone is confirude to display the timetable and events in local time.
This commit is contained in:
parent
1ac607a712
commit
41528e8193
2 changed files with 121 additions and 67 deletions
|
@ -18,7 +18,7 @@
|
|||
<h4>Timeslots</h4>
|
||||
<ul>
|
||||
<li v-for="slot in event.slots" :key="slot.id">
|
||||
{{ slot.start }} - {{ slot.end }}
|
||||
{{ formatTime(slot.start) }} - {{ formatTime(slot.end) }}
|
||||
<button
|
||||
v-if="session && event.slots.length > 1"
|
||||
class="interested"
|
||||
|
@ -37,14 +37,21 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { DateTime } from 'luxon';
|
||||
import type { ScheduleEvent } from '~/shared/types/schedule';
|
||||
|
||||
defineProps<{
|
||||
event: ScheduleEvent
|
||||
}>()
|
||||
|
||||
const { data: session, refresh: refreshSession } = useAccountSession();
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const { data: session, refresh: refreshSession } = await useAccountSession();
|
||||
const interestedIds = computed(() => new Set(session.value?.account.interestedIds ?? []));
|
||||
const timezone = computed(() => session.value?.account.timezone ?? runtimeConfig.public.defaultTimezone);
|
||||
|
||||
function formatTime(time: string) {
|
||||
return DateTime.fromISO(time, { zone: timezone.value }).toFormat("yyyy-LL-dd HH:mm");
|
||||
}
|
||||
|
||||
async function toggle(id: string, slotIds?: string[]) {
|
||||
let newIds = [...session.value!.account.interestedIds ?? []];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue