From 703695ffe54724e2c362afe15ccefffc84a6090d Mon Sep 17 00:00:00 2001
From: Ivan Kuzmenko <6745157+rndtrash@users.noreply.github.com>
Date: Sun, 16 Nov 2025 06:28:51 +0300
Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B0=D0=BD=D0=B5=D0=BB=D1=8C=20=D0=BE?=
=?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BE=D0=B1?=
=?UTF-8?q?=D1=8B=D1=82=D0=B8=D1=8F=20=D0=BD=D0=B0=20=D1=81=D1=82=D1=80?=
=?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=86=D0=B5=20=D0=B1=D0=BB=D0=BE=D0=B3=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/lib/components/CountdownClock.svelte | 99 ++++++++++++++++++++++++
src/lib/util/Blogs.ts | 22 ++++++
src/routes/blog/[slug]/+page.svelte | 84 ++++++++++++++++++--
3 files changed, 200 insertions(+), 5 deletions(-)
create mode 100644 src/lib/components/CountdownClock.svelte
diff --git a/src/lib/components/CountdownClock.svelte b/src/lib/components/CountdownClock.svelte
new file mode 100644
index 0000000..71c95c9
--- /dev/null
+++ b/src/lib/components/CountdownClock.svelte
@@ -0,0 +1,99 @@
+
+
+
+ {#if daysLeft > 0}
+
{dateDurationLong.format({ days: daysLeft })}
+ {/if}
+
+
{hoursLeft[0]}
+
{hoursLeft[1]}
+
:
+
{minutesLeft[0]}
+
{minutesLeft[1]}
+
:
+
{secondsLeft[0]}
+
{secondsLeft[1]}
+
+
+
+
diff --git a/src/lib/util/Blogs.ts b/src/lib/util/Blogs.ts
index 5878e26..e10d18d 100644
--- a/src/lib/util/Blogs.ts
+++ b/src/lib/util/Blogs.ts
@@ -1,6 +1,28 @@
export const THUMBNAIL_DEFAULT = "https://teasanctuary.ru/common/background-day.webp";
export const BLOG_POST_FRESHNESS_MILLIS = 3 * 24 * 60 * 60 * 1000; // 3 дня
+export enum EventStatus {
+ NotEvent = 0,
+ NotStarted,
+ InProgress,
+ IsOver
+}
+
+export function postEventStatus(post: App.BlogPost): EventStatus {
+ if (post.type !== 'event' || post.dateEventFrom === undefined || post.dateEventTo === undefined) {
+ return EventStatus.NotEvent;
+ }
+
+ const currentTime = new Date().valueOf();
+ const eventStart = new Date(post.dateEventFrom).valueOf();
+ if (currentTime < eventStart) return EventStatus.NotStarted;
+
+ const eventEnd = new Date(post.dateEventTo).valueOf();
+ if (currentTime < eventEnd) return EventStatus.InProgress;
+
+ return EventStatus.IsOver;
+}
+
export type PostComparer = (a: App.BlogPost, b: App.BlogPost) => number;
export const sortPostsByPostDate: PostComparer = (a, b) => new Date(b.date!).valueOf() - new Date(a.date!).valueOf();
diff --git a/src/routes/blog/[slug]/+page.svelte b/src/routes/blog/[slug]/+page.svelte
index 0b0b105..b891e4d 100644
--- a/src/routes/blog/[slug]/+page.svelte
+++ b/src/routes/blog/[slug]/+page.svelte
@@ -1,12 +1,20 @@