🐛 Fix birthday check in
This commit is contained in:
@@ -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 accountBirthday = accountProfile?.Birthday;
|
||||||
|
|
||||||
var now = SystemClock.Instance.GetCurrentInstant().InUtc().Date;
|
var now = SystemClock.Instance.GetCurrentInstant();
|
||||||
var birthdayDate = accountBirthday?.InUtc().Date;
|
|
||||||
var isBirthday = birthdayDate.HasValue && birthdayDate.Value.Month == now.Month && birthdayDate.Value.Day == now.Day;
|
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;
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user