From f13469c052846acf2a4bb580d406b5ba5d3ae14f Mon Sep 17 00:00:00 2001
From: Denis Tingaikin <denis.tingajkin@xored.com>
Date: Fri, 27 Dec 2024 13:33:42 +0300
Subject: [PATCH] use the second day to protect the date popup against the
 effects of time zone changes. (#7567)

Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
---
 packages/ui/src/components/calendar/DatePopup.svelte | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/packages/ui/src/components/calendar/DatePopup.svelte b/packages/ui/src/components/calendar/DatePopup.svelte
index 307762d726..bd0a9dfe60 100644
--- a/packages/ui/src/components/calendar/DatePopup.svelte
+++ b/packages/ui/src/components/calendar/DatePopup.svelte
@@ -86,7 +86,9 @@
     }
   }
   const changeMonth = (date: Date): Date => {
-    return new Date(date.getFullYear(), date.getMonth() + 1, 1)
+    // We should use the second day to protect the result of the month-shifted against the effects of time zone changes.
+    const secondDay = 2
+    return new Date(date.getFullYear(), date.getMonth() + 1, secondDay)
   }
 
   $: if (viewDate) viewDateSec = changeMonth(viewDate)