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 { ref } from 'vue';
|
||||
import ContextMenu from '@partials/ContextMenu.vue';
|
||||
import { formatTime } from "@/helpers/DateFormatter.ts";
|
||||
|
||||
const emit = defineEmits([
|
||||
'contextMenuEditInstance',
|
||||
|
@ -57,18 +58,13 @@ const contextMenuAction = (action: ShowEventActionTrigger, item: Object) => {
|
|||
emit(action, selectedShowInstance.value.showInstanceIndex);
|
||||
contextMenu.value.visible = false;
|
||||
};
|
||||
|
||||
const formatTime = (dateString: string) => {
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleTimeString([], {hour: '2-digit', minute: '2-digit'});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-calendar
|
||||
ref="calendar"
|
||||
v-model="currentCalendarDate"
|
||||
:events="shows"
|
||||
:events="props.shows"
|
||||
:event-margin-bottom="3"
|
||||
@contextmenu:event="openContextMenu"
|
||||
>
|
||||
|
@ -81,7 +77,7 @@ const formatTime = (dateString: string) => {
|
|||
>
|
||||
<span>{{ event.title }}</span>
|
||||
<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>
|
||||
</template>
|
||||
</v-calendar>
|
||||
|
|
|
@ -6,7 +6,7 @@ export interface calendarShowEvent {
|
|||
title: string,
|
||||
color: string,
|
||||
start: Date,
|
||||
end: Date
|
||||
end: Date,
|
||||
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 {
|
||||
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 ms = new Date().setHours(h,m);
|
||||
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