Skip to content

Commit

Permalink
style: getFormattedDate를 간결하게 수정
Browse files Browse the repository at this point in the history
- padStart를 활용하여 getFormattedDate 메서드를 간결하게 수정
  • Loading branch information
JoonSoo-Kim committed Dec 4, 2023
1 parent 8c7512b commit b4a0ff7
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions BE/src/stat/stat.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")}`;
}
}

0 comments on commit b4a0ff7

Please sign in to comment.