Use server time on timeline

pull/1/head
Made Baruna 2021-03-12 18:39:43 +07:00
parent 21a39b5d34
commit c1991992ae
3 changed files with 10 additions and 4 deletions

View File

@ -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 () => {

View File

@ -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 () => {

View File

@ -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();