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