mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2024-11-23 07:17:43 +01:00
Use server time on timeline
This commit is contained in:
parent
21a39b5d34
commit
c1991992ae
3 changed files with 10 additions and 4 deletions
|
@ -1,14 +1,15 @@
|
|||
<script>
|
||||
import dayjs from 'dayjs';
|
||||
import { onMount } from 'svelte';
|
||||
import { getCurrentTime } from '../../stores/server';
|
||||
|
||||
export let event;
|
||||
|
||||
|
||||
let now = dayjs();
|
||||
|
||||
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 a new issue