From 12f91dd1a9bbcd0a93f9f5bf91bf99f1af5f4bb9 Mon Sep 17 00:00:00 2001 From: SUZUKI Sosuke Date: Sat, 13 Jan 2024 03:42:19 +0900 Subject: [PATCH] Use `ISOString` for `getFormattedDate` (#15914) Use `ISOString` --- scripts/release/get-formatted-date.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/release/get-formatted-date.js b/scripts/release/get-formatted-date.js index 21b96e12c..0d7c40c8a 100644 --- a/scripts/release/get-formatted-date.js +++ b/scripts/release/get-formatted-date.js @@ -1,8 +1,11 @@ // TODO: Implement this in `utils.js` when jest.importActual is landed. export default function getFormattedDate() { const date = new Date(); - const year = date.getFullYear(); - const month = String(date.getMonth() + 1).padStart(2, "0"); - const day = String(date.getDate()).padStart(2, "0"); + const isoStr = date.toISOString(); + + const year = isoStr.slice(0, 4); + const month = isoStr.slice(5, 7); + const day = isoStr.slice(8, 10); + return { year, month, day }; }