fix(backend/get-following-birthday-users): 一部の月でbirthdayのタイムスタンプが1ヶ月ズレる問題を修正 (MisskeyIO#587)

This commit is contained in:
まっちゃとーにゅ 2024-04-01 03:55:03 +09:00 committed by GitHub
parent 9f6b433df2
commit eeedd500bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -126,13 +126,16 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
)
).map(u => [u.id, u]));
const now = new Date();
return birthdayUsers
.map(item => {
const birthday = new Date();
birthday.setMonth(Math.floor(item.birthday_date / 100) - 1);
birthday.setDate(item.birthday_date % 100);
birthday.setHours(0, 0, 0, 0);
if (birthday.getTime() < Date.now()) birthday.setFullYear(new Date().getFullYear() + 1);
const birthday = new Date(
now.getFullYear(),
Math.floor(item.birthday_date / 100) - 1,
item.birthday_date % 100,
0, 0, 0, 0,
);
if (birthday.getTime() < now.getTime()) birthday.setFullYear(now.getFullYear() + 1);
return { birthday: birthday.toISOString(), user: users.get(item.user_id) };
})
.filter(item => item.user !== undefined)