From eeedd500bbd93791243aaa6bd27b76b7a2977a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Mon, 1 Apr 2024 03:55:03 +0900 Subject: [PATCH] =?UTF-8?q?fix(backend/get-following-birthday-users):=20?= =?UTF-8?q?=E4=B8=80=E9=83=A8=E3=81=AE=E6=9C=88=E3=81=A7birthday=E3=81=AE?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=A0=E3=82=B9=E3=82=BF=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=81=8C1=E3=83=B6=E6=9C=88=E3=82=BA=E3=83=AC=E3=82=8B?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE=E6=AD=A3=20(MisskeyIO#587)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../endpoints/users/get-following-birthday-users.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/users/get-following-birthday-users.ts b/packages/backend/src/server/api/endpoints/users/get-following-birthday-users.ts index 9377583df0..bf35fc9e4d 100644 --- a/packages/backend/src/server/api/endpoints/users/get-following-birthday-users.ts +++ b/packages/backend/src/server/api/endpoints/users/get-following-birthday-users.ts @@ -126,13 +126,16 @@ export default class extends Endpoint { // 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)