fix(FE): Fix typos and dates
This commit is contained in:
parent
3f49b3c085
commit
cd7627b3bb
3 changed files with 41 additions and 8 deletions
|
@ -5,6 +5,7 @@ import type {calendarShowEvent, ShowEventActionTrigger} from "@models/misc/calen
|
||||||
import {calendarShowEventMenu} from "@models/misc/calendarShowEvent";
|
import {calendarShowEventMenu} from "@models/misc/calendarShowEvent";
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import ContextMenu from '@partials/ContextMenu.vue';
|
import ContextMenu from '@partials/ContextMenu.vue';
|
||||||
|
import { formatTime } from "@/helpers/DateFormatter.ts";
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
'contextMenuEditInstance',
|
'contextMenuEditInstance',
|
||||||
|
@ -57,18 +58,13 @@ const contextMenuAction = (action: ShowEventActionTrigger, item: Object) => {
|
||||||
emit(action, selectedShowInstance.value.showInstanceIndex);
|
emit(action, selectedShowInstance.value.showInstanceIndex);
|
||||||
contextMenu.value.visible = false;
|
contextMenu.value.visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatTime = (dateString: string) => {
|
|
||||||
const date = new Date(dateString);
|
|
||||||
return date.toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<v-calendar
|
<v-calendar
|
||||||
ref="calendar"
|
ref="calendar"
|
||||||
v-model="currentCalendarDate"
|
v-model="currentCalendarDate"
|
||||||
:events="shows"
|
:events="props.shows"
|
||||||
:event-margin-bottom="3"
|
:event-margin-bottom="3"
|
||||||
@contextmenu:event="openContextMenu"
|
@contextmenu:event="openContextMenu"
|
||||||
>
|
>
|
||||||
|
@ -81,7 +77,7 @@ const formatTime = (dateString: string) => {
|
||||||
>
|
>
|
||||||
<span>{{ event.title }}</span>
|
<span>{{ event.title }}</span>
|
||||||
<br/>
|
<br/>
|
||||||
<span>{{ formatTime(event.start as string) }} - {{ formatTime(event.end as string) }}</span>
|
<span>{{ formatTime(event.start) as string }} - {{ formatTime(event.end) as string }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</v-calendar>
|
</v-calendar>
|
||||||
|
|
|
@ -6,7 +6,7 @@ export interface calendarShowEvent {
|
||||||
title: string,
|
title: string,
|
||||||
color: string,
|
color: string,
|
||||||
start: Date,
|
start: Date,
|
||||||
end: Date
|
end: Date,
|
||||||
timed: boolean,
|
timed: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import {useAuthStore} from "@/stores/auth.store.ts";
|
||||||
|
import { DateTime } from "luxon";
|
||||||
|
|
||||||
export function dateFormatter(date: Date = new Date()): string {
|
export function dateFormatter(date: Date = new Date()): string {
|
||||||
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
|
return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
|
||||||
}
|
}
|
||||||
|
@ -28,4 +31,38 @@ export function getHoursMinutesFromString(timeString: string): Date {
|
||||||
const [ h, m ] = timeString.split(":");
|
const [ h, m ] = timeString.split(":");
|
||||||
const ms = new Date().setHours(h,m);
|
const ms = new Date().setHours(h,m);
|
||||||
return new Date(ms)
|
return new Date(ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function convertToUserTimezoneString(dateString: string): string {
|
||||||
|
const auth = useAuthStore();
|
||||||
|
const timezone = auth.userData.timezone;
|
||||||
|
const dateTime = DateTime.fromISO(dateString).setZone(timezone);
|
||||||
|
return dateTime.toISO();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function convertToUserTimezoneDate(dateString: string): Date {
|
||||||
|
const auth = useAuthStore();
|
||||||
|
const timezone = auth.userData.timezone;
|
||||||
|
const dateTime = DateTime.fromISO(dateString).setZone(timezone);
|
||||||
|
return dateTime.toJSDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function convertToUTCString(dateString: string): string {
|
||||||
|
const auth = useAuthStore();
|
||||||
|
const timezone = auth.userData.timezone;
|
||||||
|
const dateTime = DateTime.fromISO(dateString, { zone: timezone });
|
||||||
|
return dateTime.toUTC().toISO();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function extractTimeUTC(timeString: string) {
|
||||||
|
const [hours, minutes] = timeString.split(':').map(Number);
|
||||||
|
const dt = DateTime.now()
|
||||||
|
.set({ hour: hours, minute: minutes, second: 0, millisecond: 0 })
|
||||||
|
.toUTC();
|
||||||
|
return dt.toFormat("HH:mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function formatTime(date: Date): string {
|
||||||
|
const luxonDate = DateTime.fromJSDate(date);
|
||||||
|
return luxonDate.toLocaleString({ hour: 'numeric', minute: 'numeric', hour12: false });
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue