🐛 Fix birthday check in

This commit is contained in:
2025-11-27 22:22:22 +08:00
parent a7f4173df7
commit 78f3873a0c
3 changed files with 20 additions and 7 deletions

View File

@@ -313,14 +313,27 @@ public class AccountEventService(
CultureInfo.CurrentCulture = cultureInfo; CultureInfo.CurrentCulture = cultureInfo;
CultureInfo.CurrentUICulture = cultureInfo; CultureInfo.CurrentUICulture = cultureInfo;
var accountBirthday = await db.AccountProfiles var accountProfile = await db.AccountProfiles
.Where(x => x.AccountId == user.Id) .Where(x => x.AccountId == user.Id)
.Select(x => x.Birthday) .Select(x => new { x.Birthday, x.TimeZone })
.FirstOrDefaultAsync(); .FirstOrDefaultAsync();
var now = SystemClock.Instance.GetCurrentInstant().InUtc().Date; var accountBirthday = accountProfile?.Birthday;
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<CheckInFortuneTip> tips; List<CheckInFortuneTip> tips;
CheckInResultLevel checkInLevel; CheckInResultLevel checkInLevel;

View File

@@ -199,6 +199,6 @@
<value>Have a Birthday Party</value> <value>Have a Birthday Party</value>
</data> </data>
<data name="FortuneTipSpecialContent_Birthday" xml:space="preserve"> <data name="FortuneTipSpecialContent_Birthday" xml:space="preserve">
<value>Happy Birthday, {}!</value> <value>Happy Birthday, {0}!</value>
</data> </data>
</root> </root>

View File

@@ -252,6 +252,6 @@
<value>过生日</value> <value>过生日</value>
</data> </data>
<data name="FortuneTipSpecialContent_Birthday" xml:space="preserve"> <data name="FortuneTipSpecialContent_Birthday" xml:space="preserve">
<value>生日快乐,{}</value> <value>生日快乐,{0}</value>
</data> </data>
</root> </root>