diff --git a/packages/app/src/Const.ts b/packages/app/src/Const.ts
index 5a87d6f3..aad62c00 100644
--- a/packages/app/src/Const.ts
+++ b/packages/app/src/Const.ts
@@ -8,6 +8,11 @@ export const Hour = 60 * 60;
*/
export const Day = Hour * 24;
+/**
+ * Day this project started
+ */
+export const Birthday = new Date(2022, 11, 17);
+
/**
* Add-on api for snort features
*/
diff --git a/packages/app/src/Pages/Layout/LogoHeader.tsx b/packages/app/src/Pages/Layout/LogoHeader.tsx
index a635993d..5dff2804 100644
--- a/packages/app/src/Pages/Layout/LogoHeader.tsx
+++ b/packages/app/src/Pages/Layout/LogoHeader.tsx
@@ -1,14 +1,20 @@
import useLogin from "../../Hooks/useLogin";
import { getCurrentSubscription } from "../../Subscription";
-import { isChristmas, isHalloween, isStPatricksDay } from "../../SnortUtils";
+import { isBirthday, isChristmas, isHalloween, isStPatricksDay } from "../../SnortUtils";
import { Link } from "react-router-dom";
import { mapPlanName } from "../subscribe";
import Icon from "@/Icons/Icon";
+import { unixNowMs } from "@snort/shared";
+import { Birthday, Day } from "@/Const";
export function LogoHeader({ showText = false }) {
const { subscriptions } = useLogin();
const currentSubscription = getCurrentSubscription(subscriptions);
const extra = () => {
+ if (isBirthday()) {
+ const age = (unixNowMs() - Birthday.getTime()) / (Day * 365_000);
+ return {age.toFixed(0)}st 🎂;
+ }
if (isHalloween()) return "🎃";
if (isStPatricksDay()) return "🍀";
if (isChristmas()) return "🎄";
@@ -29,8 +35,8 @@ export function LogoHeader({ showText = false }) {
)}
{showText && (
- {extra()}
{CONFIG.appName}
+ {extra()}
)}
diff --git a/packages/app/src/SnortUtils/index.ts b/packages/app/src/SnortUtils/index.ts
index 2c99a5de..5272cca2 100644
--- a/packages/app/src/SnortUtils/index.ts
+++ b/packages/app/src/SnortUtils/index.ts
@@ -19,7 +19,7 @@ import {
UserMetadata,
} from "@snort/system";
import { isHex, isOffline } from "@snort/shared";
-import { Day } from "@/Const";
+import { Birthday, Day } from "@/Const";
import AnimalName from "@/Element/User/AnimalName";
export const sha256 = (str: string | Uint8Array): u256 => {
@@ -472,26 +472,30 @@ export function isFormElement(target: HTMLElement): boolean {
}
const ThisYear = new Date().getFullYear();
-const SeasonalEventsWindow = 7; // n days before
-const IsTheSeason = (target: Date) => {
+const IsTheSeason = (target: Date, window: number) => {
const now = new Date();
const days = (target.getTime() - now.getTime()) / (Day * 1000);
- return days > 0 && days <= SeasonalEventsWindow;
+ return (days >= 0 && days <= window) || (now.getDate() === target.getDate() && now.getMonth() === target.getMonth());
};
export const isHalloween = () => {
const event = new Date(ThisYear, 9, 31);
- return IsTheSeason(event);
+ return IsTheSeason(event, 7);
};
export const isStPatricksDay = () => {
const event = new Date(ThisYear, 2, 17);
- return IsTheSeason(event);
+ return IsTheSeason(event, 7);
};
export const isChristmas = () => {
const event = new Date(ThisYear, 11, 25);
- return IsTheSeason(event);
+ return IsTheSeason(event, 30);
+};
+
+export const isBirthday = () => {
+ const event = new Date(ThisYear, Birthday.getMonth(), Birthday.getDate());
+ return IsTheSeason(event, 1);
};
export function getDisplayName(user: UserMetadata | undefined, pubkey: HexKey): string {