From 44ce3c455187939c8ebbf4db657fa756401839ec Mon Sep 17 00:00:00 2001 From: kim jeong yong Date: Fri, 5 Dec 2025 13:28:00 +0900 Subject: [PATCH] =?UTF-8?q?weather=20=EB=B8=94=EB=A1=9D=EC=9D=98=20localDa?= =?UTF-8?q?te=20=ED=8F=AC=EB=A7=B7=ED=8C=85=20=EB=A1=9C=EC=A7=81=EC=9D=84?= =?UTF-8?q?=20=EC=97=B0=C2=B7=EC=9B=94=C2=B7=EC=9D=BC=EC=9D=84=20=EB=AA=85?= =?UTF-8?q?=EC=8B=9C=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=B6=94=EC=B6=9C?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=84=B0=EB=A7=81.=20skyCodeMap=EC=9D=98=20?= =?UTF-8?q?=ED=82=A4=EB=A5=BC=20=EB=AC=B8=EC=9E=90=EC=97=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=88=AB=EC=9E=90=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=ED=95=B4=20=EC=9D=BC=EA=B4=80=EC=84=B1=20=EA=B0=95=ED=99=94.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocks/block_expansion_weather.js | 59 +++++++++++-------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/src/playground/blocks/block_expansion_weather.js b/src/playground/blocks/block_expansion_weather.js index 697af75ab9..4d7189048a 100644 --- a/src/playground/blocks/block_expansion_weather.js +++ b/src/playground/blocks/block_expansion_weather.js @@ -32,7 +32,12 @@ Entry.EXPANSION_BLOCK.weather = { return; } Entry.EXPANSION_BLOCK.weather.date = new Date(); - Entry.EXPANSION_BLOCK.weather.localDate = new Date().toLocaleDateString().replaceAll('.', '').replaceAll(' ', '') + const localDate = new Date(); + const localDateYear = localDate.getFullYear(); + const localDateMonth = String(localDate.getMonth() + 1).padStart(2, '0'); + const localDateDay = String(localDate.getDate()).padStart(2, '0'); + // eslint-disable-next-line max-len + Entry.EXPANSION_BLOCK.weather.localDate = `${localDateYear}${localDateMonth}${localDateDay}`; Entry.EXPANSION_BLOCK.weather.getData('week', 'Seoul', 'today'); Entry.EXPANSION_BLOCK.weather.getData('hour', 'Seoul', '00'); Entry.EXPANSION_BLOCK.weather.getData('now', 'Seoul'); @@ -90,29 +95,29 @@ Entry.EXPANSION_BLOCK.weather = { } const skyCodeMap = { - '1': 'sunny', //"맑음", - '2': 'partly_cloudy', //"구름조금", - '3': 'cloudy', //"흐림", - '4': 'rainy', //"비", - '5': 'snowy', //"눈", - '6': 'sleet', //"눈비", + 1: 'sunny', //"맑음", + 2: 'partly_cloudy', //"구름조금", + 3: 'cloudy', //"흐림", + 4: 'rainy', //"비", + 5: 'snowy', //"눈", + 6: 'sleet', //"눈비", - '7': 'rainy', //"소나기", - '8': 'snowy', //"소낙눈", - '9': 'cloudy', //"안개", - '10': 'rainy', //"뇌우", - '11': 'cloudy', //"차차 흐려짐", - '12': 'rainy', //"흐려져 뇌우", - '13': 'rainy', //"흐려져 비", - '14': 'snowy', //"흐려져 눈", - '15': 'sleet', //"흐려져 눈비", - '16': 'cloudy', //"흐린 후 갬", - '17': 'rainy', //"뇌우 후 갬", - '18': 'rainy', //"비 후 갬", - '19': 'snowy', //"눈 후 갬", - '20': 'sleet', //"눈비 후 갬", - '21': 'mostly_cloudy', //"구름많음", - '22': 'cloudy', + 7: 'rainy', //"소나기", + 8: 'snowy', //"소낙눈", + 9: 'cloudy', //"안개", + 10: 'rainy', //"뇌우", + 11: 'cloudy', //"차차 흐려짐", + 12: 'rainy', //"흐려져 뇌우", + 13: 'rainy', //"흐려져 비", + 14: 'snowy', //"흐려져 눈", + 15: 'sleet', //"흐려져 눈비", + 16: 'cloudy', //"흐린 후 갬", + 17: 'rainy', //"뇌우 후 갬", + 18: 'rainy', //"비 후 갬", + 19: 'snowy', //"눈 후 갬", + 20: 'sleet', //"눈비 후 갬", + 21: 'mostly_cloudy', //"구름많음", + 22: 'cloudy', }; if (skyCodeMap[sky_code]) { @@ -170,7 +175,10 @@ Entry.EXPANSION_BLOCK.weather = { default: break; } - return date.toLocaleDateString().replaceAll('.', '').replaceAll(' ', ''); + 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}`; }, locationMap: { Seoul: { @@ -555,7 +563,7 @@ Entry.EXPANSION_BLOCK.weather = { }, }; -Entry.EXPANSION_BLOCK.weather.getBlocks = function() { +Entry.EXPANSION_BLOCK.weather.getBlocks = function () { const params = { getDate(isPython = false) { const param = { @@ -1892,6 +1900,7 @@ Entry.EXPANSION_BLOCK.weather.getBlocks = function() { location, script.getField('DATE', script) ); + return apiResult.sky; }, syntax: {