From 3e0c9e79937a3d8da23d7e43743a7810485e3c6f Mon Sep 17 00:00:00 2001
From: Fuwn
Date: Sun, 17 Mar 2024 05:25:40 -0700
Subject: fix(umamusume): null-check birthdays
---
src/lib/Locale/english.ts | 6 +++
src/lib/Locale/japanese.ts | 7 +++
src/lib/Locale/layout.ts | 1 +
src/lib/Tools/UmaMusumeBirthdays.svelte | 91 +++++++++++++++++++--------------
4 files changed, 66 insertions(+), 39 deletions(-)
(limited to 'src')
diff --git a/src/lib/Locale/english.ts b/src/lib/Locale/english.ts
index d994475f..34666978 100644
--- a/src/lib/Locale/english.ts
+++ b/src/lib/Locale/english.ts
@@ -297,6 +297,12 @@ const English: Locale = {
minute: 'numeric'
// second: 'numeric'
// timeZoneName: 'short'
+ }).format,
+ dayFormatter: new Intl.DateTimeFormat('en-US', {
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ weekday: 'long'
}).format
};
diff --git a/src/lib/Locale/japanese.ts b/src/lib/Locale/japanese.ts
index 6004ce4e..3caea474 100644
--- a/src/lib/Locale/japanese.ts
+++ b/src/lib/Locale/japanese.ts
@@ -301,6 +301,13 @@ const Japanese: Locale = {
minute: 'numeric'
// second: 'numeric'
// timeZoneName: 'short'
+ }).format,
+ dayFormatter: new Intl.DateTimeFormat('ja-JP', {
+ // era: 'long',
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ weekday: 'long'
}).format
};
diff --git a/src/lib/Locale/layout.ts b/src/lib/Locale/layout.ts
index 2064ed00..c1a0df5f 100644
--- a/src/lib/Locale/layout.ts
+++ b/src/lib/Locale/layout.ts
@@ -277,4 +277,5 @@ export interface Locale {
parseError: LocaleValue;
};
dateFormatter: (date?: number | Date | undefined) => string;
+ dayFormatter: (date?: number | Date | undefined) => string;
}
diff --git a/src/lib/Tools/UmaMusumeBirthdays.svelte b/src/lib/Tools/UmaMusumeBirthdays.svelte
index d941cabe..8a8e33db 100644
--- a/src/lib/Tools/UmaMusumeBirthdays.svelte
+++ b/src/lib/Tools/UmaMusumeBirthdays.svelte
@@ -8,6 +8,7 @@
import Message from '$lib/Loading/Message.svelte';
import tooltip from '$lib/Tooltip/tooltip';
import settings from '$stores/settings';
+ import locale from '$stores/locale';
interface Birthday {
birth_day: number;
@@ -51,50 +52,62 @@
{:then birthdays}
- {@const todaysBirthdays = birthdays.filter(
- (birthday) => birthday.birth_month === month && birthday.birth_day === day
- )}
+ {#if birthdays}
+ {@const todaysBirthdays = birthdays.filter(
+ (birthday) => birthday.birth_month === month && birthday.birth_day === day
+ )}
-
-
+
+
-
-
+
+
- {#if todaysBirthdays.length === 0}
-
+ {#if todaysBirthdays.length === 0}
+
+ {:else}
+
+ {#each todaysBirthdays as birthday}
+ {@const name = $settings.displayLanguage === 'en' ? birthday.name_en : birthday.name_jp}
+ {@const nameOther =
+ $settings.displayLanguage === 'ja' ? birthday.name_en : birthday.name_jp}
+
+
+ {/each}
+
+ {/if}
{:else}
-
- {#each todaysBirthdays as birthday}
- {@const name = $settings.displayLanguage === 'en' ? birthday.name_en : birthday.name_jp}
- {@const nameOther =
- $settings.displayLanguage === 'ja' ? birthday.name_en : birthday.name_jp}
+
-
- {/each}
-
+
{/if}
{:catch}
--
cgit v1.2.3