From b4a0ff721b3f913f8b626910fee5e15ee0c0d3e1 Mon Sep 17 00:00:00 2001 From: JoonSoo-Kim Date: Mon, 4 Dec 2023 15:42:53 +0900 Subject: [PATCH] =?UTF-8?q?style:=20getFormattedDate=EB=A5=BC=20=EA=B0=84?= =?UTF-8?q?=EA=B2=B0=ED=95=98=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - padStart를 활용하여 getFormattedDate 메서드를 간결하게 수정 --- BE/src/stat/stat.service.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/BE/src/stat/stat.service.ts b/BE/src/stat/stat.service.ts index 3bbdf78..0e1d331 100644 --- a/BE/src/stat/stat.service.ts +++ b/BE/src/stat/stat.service.ts @@ -111,18 +111,9 @@ export class StatService { private getFormattedDate(date: Date): string { date.setHours(date.getHours() + 9); - let formattedDate; - formattedDate = date.getFullYear().toString() + "-"; - formattedDate += - date.getMonth() + 1 < 10 - ? "0" + (date.getMonth() + 1).toString() - : (date.getMonth() + 1).toString(); - formattedDate += "-"; - formattedDate += - date.getDate() < 10 - ? "0" + date.getDate().toString() - : date.getDate().toString(); - return formattedDate; + return `${date.getFullYear()}-${(date.getMonth() + 1) + .toString() + .padStart(2, "0")}-${date.getDate().toString().padStart(2, "0")}`; } }