From 78f3873a0c193373d1e77ea9aef53c9b052f55db Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 27 Nov 2025 22:22:22 +0800 Subject: [PATCH] :bug: Fix birthday check in --- .../Account/AccountEventService.cs | 23 +++++++++++++++---- .../Localization/AccountEventResource.resx | 2 +- .../AccountEventResource.zh-hans.resx | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/DysonNetwork.Pass/Account/AccountEventService.cs b/DysonNetwork.Pass/Account/AccountEventService.cs index 33ae420..2ea0068 100644 --- a/DysonNetwork.Pass/Account/AccountEventService.cs +++ b/DysonNetwork.Pass/Account/AccountEventService.cs @@ -313,14 +313,27 @@ public class AccountEventService( CultureInfo.CurrentCulture = cultureInfo; CultureInfo.CurrentUICulture = cultureInfo; - var accountBirthday = await db.AccountProfiles + var accountProfile = await db.AccountProfiles .Where(x => x.AccountId == user.Id) - .Select(x => x.Birthday) + .Select(x => new { x.Birthday, x.TimeZone }) .FirstOrDefaultAsync(); + + var accountBirthday = accountProfile?.Birthday; - var now = SystemClock.Instance.GetCurrentInstant().InUtc().Date; - var birthdayDate = accountBirthday?.InUtc().Date; - var isBirthday = birthdayDate.HasValue && birthdayDate.Value.Month == now.Month && birthdayDate.Value.Day == now.Day; + var now = SystemClock.Instance.GetCurrentInstant(); + + var userTimeZone = DateTimeZone.Utc; + if (!string.IsNullOrEmpty(accountProfile?.TimeZone)) + { + userTimeZone = DateTimeZoneProviders.Tzdb.GetZoneOrNull(accountProfile.TimeZone) ?? DateTimeZone.Utc; + } + + var todayInUserTz = now.InZone(userTimeZone).Date; + var birthdayDate = accountBirthday?.InZone(userTimeZone).Date; + + var isBirthday = birthdayDate.HasValue && + birthdayDate.Value.Month == todayInUserTz.Month && + birthdayDate.Value.Day == todayInUserTz.Day; List tips; CheckInResultLevel checkInLevel; diff --git a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx index 11ff27e..e118db2 100644 --- a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx +++ b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.resx @@ -199,6 +199,6 @@ Have a Birthday Party - Happy Birthday, {}! + Happy Birthday, {0}! diff --git a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx index 22d7c78..606a831 100644 --- a/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx +++ b/DysonNetwork.Pass/Resources/Localization/AccountEventResource.zh-hans.resx @@ -252,6 +252,6 @@ 过生日 - 生日快乐,{}! + 生日快乐,{0}!