Count the timezone difference in wish detail

pull/1/head
Made Baruna 2021-03-19 01:23:07 +08:00
parent c4cc2a7e3e
commit 58c7fb452f
4 changed files with 15 additions and 5 deletions

View File

@ -144,7 +144,8 @@
"banner": "Banner", "banner": "Banner",
"roll": "#Roll", "roll": "#Roll",
"totalThisBanner": "Total pull on this banner", "totalThisBanner": "Total pull on this banner",
"worth": "Worth" "worth": "Worth",
"loading": "Loading... (If this stuck, change your server on settings page)"
} }
}, },
"calculator": { "calculator": {

View File

@ -144,7 +144,8 @@
"banner": "Banner", "banner": "Banner",
"roll": "#Roll", "roll": "#Roll",
"totalThisBanner": "Total pull di banner ini", "totalThisBanner": "Total pull di banner ini",
"worth": "Setara dengan" "worth": "Setara dengan",
"loading": "Loading... (Kalau tidak selesai-selesai, ganti server di halaman settings)"
} }
}, },
"calculator": { "calculator": {

View File

@ -22,6 +22,7 @@
import { weaponList } from '../../data/weaponList'; import { weaponList } from '../../data/weaponList';
import { getAccountPrefix } from '../../stores/account'; import { getAccountPrefix } from '../../stores/account';
import { fromRemote, readSave } from '../../stores/saveManager'; import { fromRemote, readSave } from '../../stores/saveManager';
import { getTimeOffset } from '../../stores/server';
Chart.defaults.global.defaultFontColor = '#cbd5e0'; Chart.defaults.global.defaultFontColor = '#cbd5e0';
Chart.defaults.global.defaultFontFamily = 'Poppins'; Chart.defaults.global.defaultFontFamily = 'Poppins';
@ -61,8 +62,11 @@
let selectedBanners; let selectedBanners;
selectedBanners = banners[bannerType].map((e) => { selectedBanners = banners[bannerType].map((e) => {
const start = dayjs(e.start, 'YYYY-MM-DD HH:mm:ss'); // banner data based on Asia time
const end = dayjs(e.end, 'YYYY-MM-DD HH:mm:ss'); const diff = 8 - getTimeOffset();
const start = dayjs(e.start, 'YYYY-MM-DD HH:mm:ss').subtract(diff, 'hour');
const end = dayjs(e.end, 'YYYY-MM-DD HH:mm:ss').subtract(diff, 'hour');
const image = `/images/banners/${e.name} ${start.format('YYYY-MM-DD')}.png`; const image = `/images/banners/${e.name} ${start.format('YYYY-MM-DD')}.png`;
return { return {
@ -390,7 +394,7 @@
</h2> </h2>
</div> </div>
{#if loading} {#if loading}
<div class="text-white pl-4 md:pl-8 mt-4">Loading...</div> <div class="text-white pl-4 md:pl-8 mt-4">{$t('wish.detail.loading')}</div>
{:else} {:else}
<div class="flex mt-4 wrapper"> <div class="flex mt-4 wrapper">
<div class="block overflow-x-auto xl:overflow-x-visible whitespace-no-wrap px"> <div class="block overflow-x-auto xl:overflow-x-visible whitespace-no-wrap px">

View File

@ -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 getTimeOffset = () => {
return timeOffset[get(server)];
}
export const getTimeDifference = () => { export const getTimeDifference = () => {
const now = dayjs(); const now = dayjs();
const local = now.utcOffset(); const local = now.utcOffset();