From 58c7fb452f567d1c54b6e30112a2259f3b6f8f8b Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Fri, 19 Mar 2021 01:23:07 +0800 Subject: [PATCH] Count the timezone difference in wish detail --- src/locales/en.json | 3 ++- src/locales/id.json | 3 ++- src/routes/wish/[id].svelte | 10 +++++++--- src/stores/server.js | 4 ++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index ffa26086..d204a47b 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -144,7 +144,8 @@ "banner": "Banner", "roll": "#Roll", "totalThisBanner": "Total pull on this banner", - "worth": "Worth" + "worth": "Worth", + "loading": "Loading... (If this stuck, change your server on settings page)" } }, "calculator": { diff --git a/src/locales/id.json b/src/locales/id.json index 0710179b..6e549827 100644 --- a/src/locales/id.json +++ b/src/locales/id.json @@ -144,7 +144,8 @@ "banner": "Banner", "roll": "#Roll", "totalThisBanner": "Total pull di banner ini", - "worth": "Setara dengan" + "worth": "Setara dengan", + "loading": "Loading... (Kalau tidak selesai-selesai, ganti server di halaman settings)" } }, "calculator": { diff --git a/src/routes/wish/[id].svelte b/src/routes/wish/[id].svelte index 355eacff..637159b7 100644 --- a/src/routes/wish/[id].svelte +++ b/src/routes/wish/[id].svelte @@ -22,6 +22,7 @@ import { weaponList } from '../../data/weaponList'; import { getAccountPrefix } from '../../stores/account'; import { fromRemote, readSave } from '../../stores/saveManager'; + import { getTimeOffset } from '../../stores/server'; Chart.defaults.global.defaultFontColor = '#cbd5e0'; Chart.defaults.global.defaultFontFamily = 'Poppins'; @@ -61,8 +62,11 @@ let selectedBanners; selectedBanners = banners[bannerType].map((e) => { - const start = dayjs(e.start, 'YYYY-MM-DD HH:mm:ss'); - const end = dayjs(e.end, 'YYYY-MM-DD HH:mm:ss'); + // banner data based on Asia time + 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`; return { @@ -390,7 +394,7 @@ {#if loading} -
Loading...
+
{$t('wish.detail.loading')}
{:else}
diff --git a/src/stores/server.js b/src/stores/server.js index 60570ea4..ef207deb 100644 --- a/src/stores/server.js +++ b/src/stores/server.js @@ -19,6 +19,10 @@ const timeOffset = { const weekdays = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']; +export const getTimeOffset = () => { + return timeOffset[get(server)]; +} + export const getTimeDifference = () => { const now = dayjs(); const local = now.utcOffset();