From f752a4420e237f8fffcd4f98655f6137a0af1b46 Mon Sep 17 00:00:00 2001 From: George Adams Date: Mon, 8 May 2023 07:10:05 -0400 Subject: [PATCH] refactor: `getToday` (#281) --- src/utils/date.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/utils/date.ts b/src/utils/date.ts index ec1dcb1..898a076 100644 --- a/src/utils/date.ts +++ b/src/utils/date.ts @@ -1,10 +1,8 @@ export const getToday = () => { const date = new Date(); - const dateString = - date.getFullYear() + - '-' + - ('0' + (date.getMonth() + 1)).slice(-2) + - '-' + - ('0' + date.getDate()).slice(-2); - return dateString; + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + + return `${year}-${month}-${day}`; };