Use server time on timeline
parent
21a39b5d34
commit
c1991992ae
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
|
import { getCurrentTime } from '../../stores/server';
|
||||||
|
|
||||||
export let event;
|
export let event;
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
now = dayjs();
|
now = getCurrentTime();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import duration from 'dayjs/plugin/duration';
|
import duration from 'dayjs/plugin/duration';
|
||||||
dayjs.extend(duration);
|
dayjs.extend(duration);
|
||||||
|
|
||||||
|
import { getCurrentTime } from '../../stores/server';
|
||||||
import { eventsData } from '../../data/timeline';
|
import { eventsData } from '../../data/timeline';
|
||||||
|
|
||||||
import EventItem from './_item.svelte';
|
import EventItem from './_item.svelte';
|
||||||
|
@ -96,7 +97,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let today = dayjs();
|
let today = getCurrentTime();
|
||||||
$: todayOffset = Math.abs(firstDay.diff(today, 'day', true));
|
$: todayOffset = Math.abs(firstDay.diff(today, 'day', true));
|
||||||
|
|
||||||
const dayTotal = Math.abs(Math.ceil(firstDay.diff(lastEventTime, 'day', true))) + 2 * padding;
|
const dayTotal = Math.abs(Math.ceil(firstDay.diff(lastEventTime, 'day', true))) + 2 * padding;
|
||||||
|
@ -135,7 +136,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
today = dayjs();
|
today = getCurrentTime();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
@ -19,6 +19,10 @@ const timeOffset = {
|
||||||
|
|
||||||
const weekdays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
const weekdays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];
|
||||||
|
|
||||||
|
export const getCurrentTime = () => {
|
||||||
|
return dayjs().utcOffset(timeOffset[get(server)]);
|
||||||
|
}
|
||||||
|
|
||||||
export const getCurrentDay = () => {
|
export const getCurrentDay = () => {
|
||||||
const time = dayjs().utcOffset(timeOffset[get(server)]);
|
const time = dayjs().utcOffset(timeOffset[get(server)]);
|
||||||
let day = time.day();
|
let day = time.day();
|
||||||
|
|
Loading…
Reference in New Issue