From cf3c3e823486c75277d258539a06bf6a7d25cac4 Mon Sep 17 00:00:00 2001
From: ThatOneCalculator <kainoa@t1c.dev>
Date: Sat, 1 Jul 2023 20:46:13 -0700
Subject: [PATCH] feat: :sparkles: celebrate on calendar when birthday

---
 packages/client/src/widgets/calendar.vue | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/packages/client/src/widgets/calendar.vue b/packages/client/src/widgets/calendar.vue
index 655308d504..1377b44bf0 100644
--- a/packages/client/src/widgets/calendar.vue
+++ b/packages/client/src/widgets/calendar.vue
@@ -5,7 +5,7 @@
 				<span class="year">{{ i18n.t("yearX", { year }) }}</span>
 				<span class="month">{{ i18n.t("monthX", { month }) }}</span>
 			</p>
-			<p v-if="month === 1 && day === 1" class="day">
+			<p v-if="(month === 1 && day === 1) || isBirthday" class="day">
 				🎉{{ i18n.t("dayX", { day })
 				}}<span style="display: inline-block; transform: scaleX(-1)"
 					>🎉</span
@@ -55,6 +55,7 @@ import {
 import { GetFormResultType } from "@/scripts/form";
 import { i18n } from "@/i18n";
 import { useInterval } from "@/scripts/use-interval";
+import { $i } from "@/account";
 
 const name = "calendar";
 
@@ -80,6 +81,8 @@ const { widgetProps, configure } = useWidgetPropsManager(
 	emit
 );
 
+const hasBirthday = Boolean($i?.birthday);
+
 const year = ref(0);
 const month = ref(0);
 const day = ref(0);
@@ -88,6 +91,7 @@ const yearP = ref(0);
 const monthP = ref(0);
 const dayP = ref(0);
 const isHoliday = ref(false);
+const isBirthday = ref(false);
 const tick = () => {
 	const now = new Date();
 	const nd = now.getDate();
@@ -121,6 +125,13 @@ const tick = () => {
 	yearP.value = (yearNumer / yearDenom) * 100;
 
 	isHoliday.value = now.getDay() === 0 || now.getDay() === 6;
+
+	if (hasBirthday) {
+		const [bdayYear, bdayMonth, bdayDay] = $i.birthday.split("-");
+		if (month.value === +bdayMonth && day.value == +bdayDay) {
+			isBirthday.value = true;
+		}
+	}
 };
 
 useInterval(tick, 1000, {