신원형

merged weather

1 +<<<<<<< HEAD
1 import fs from 'fs/promises' 2 import fs from 'fs/promises'
2 import { login, load, logout } from './khcanvas.js'; 3 import { login, load, logout } from './khcanvas.js';
3 4
5 +=======
6 +>>>>>>> weather
......
...@@ -8,7 +8,12 @@ ...@@ -8,7 +8,12 @@
8 "name": "study-or-enjoy", 8 "name": "study-or-enjoy",
9 "version": "1.0.0", 9 "version": "1.0.0",
10 "dependencies": { 10 "dependencies": {
11 + "@types/axios": "^0.14.0",
11 "@types/selenium-webdriver": "^4.1.0", 12 "@types/selenium-webdriver": "^4.1.0",
13 +<<<<<<< HEAD
14 +=======
15 + "axios": "^0.27.2",
16 +>>>>>>> weather
12 "mocha": "^10.0.0", 17 "mocha": "^10.0.0",
13 "selenium-webdriver": "^4.1.2" 18 "selenium-webdriver": "^4.1.2"
14 }, 19 },
...@@ -100,6 +105,18 @@ ...@@ -100,6 +105,18 @@
100 "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", 105 "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
101 "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", 106 "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
102 "dev": true 107 "dev": true
108 +<<<<<<< HEAD
109 +=======
110 + },
111 + "node_modules/@types/axios": {
112 + "version": "0.14.0",
113 + "resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz",
114 + "integrity": "sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ==",
115 + "deprecated": "This is a stub types definition for axios (https://github.com/mzabriskie/axios). axios provides its own type definitions, so you don't need @types/axios installed!",
116 + "dependencies": {
117 + "axios": "*"
118 + }
119 +>>>>>>> weather
103 }, 120 },
104 "node_modules/@types/node": { 121 "node_modules/@types/node": {
105 "version": "17.0.35", 122 "version": "17.0.35",
...@@ -211,6 +228,20 @@ ...@@ -211,6 +228,20 @@
211 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 228 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
212 "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" 229 "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
213 }, 230 },
231 + "node_modules/asynckit": {
232 + "version": "0.4.0",
233 + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
234 + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
235 + },
236 + "node_modules/axios": {
237 + "version": "0.27.2",
238 + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
239 + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
240 + "dependencies": {
241 + "follow-redirects": "^1.14.9",
242 + "form-data": "^4.0.0"
243 + }
244 + },
214 "node_modules/balanced-match": { 245 "node_modules/balanced-match": {
215 "version": "1.0.2", 246 "version": "1.0.2",
216 "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 247 "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
...@@ -346,6 +377,17 @@ ...@@ -346,6 +377,17 @@
346 "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 377 "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
347 "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" 378 "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
348 }, 379 },
380 + "node_modules/combined-stream": {
381 + "version": "1.0.8",
382 + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
383 + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
384 + "dependencies": {
385 + "delayed-stream": "~1.0.0"
386 + },
387 + "engines": {
388 + "node": ">= 0.8"
389 + }
390 + },
349 "node_modules/concat-map": { 391 "node_modules/concat-map": {
350 "version": "0.0.1", 392 "version": "0.0.1",
351 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 393 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
...@@ -407,6 +449,17 @@ ...@@ -407,6 +449,17 @@
407 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", 449 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
408 "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", 450 "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
409 "dev": true 451 "dev": true
452 +<<<<<<< HEAD
453 +=======
454 + },
455 + "node_modules/delayed-stream": {
456 + "version": "1.0.0",
457 + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
458 + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
459 + "engines": {
460 + "node": ">=0.4.0"
461 + }
462 +>>>>>>> weather
410 }, 463 },
411 "node_modules/diff": { 464 "node_modules/diff": {
412 "version": "5.0.0", 465 "version": "5.0.0",
...@@ -725,6 +778,41 @@ ...@@ -725,6 +778,41 @@
725 "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", 778 "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz",
726 "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", 779 "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==",
727 "dev": true 780 "dev": true
781 +<<<<<<< HEAD
782 +=======
783 + },
784 + "node_modules/follow-redirects": {
785 + "version": "1.15.0",
786 + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz",
787 + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==",
788 + "funding": [
789 + {
790 + "type": "individual",
791 + "url": "https://github.com/sponsors/RubenVerborgh"
792 + }
793 + ],
794 + "engines": {
795 + "node": ">=4.0"
796 + },
797 + "peerDependenciesMeta": {
798 + "debug": {
799 + "optional": true
800 + }
801 + }
802 + },
803 + "node_modules/form-data": {
804 + "version": "4.0.0",
805 + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
806 + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
807 + "dependencies": {
808 + "asynckit": "^0.4.0",
809 + "combined-stream": "^1.0.8",
810 + "mime-types": "^2.1.12"
811 + },
812 + "engines": {
813 + "node": ">= 6"
814 + }
815 +>>>>>>> weather
728 }, 816 },
729 "node_modules/fs.realpath": { 817 "node_modules/fs.realpath": {
730 "version": "1.0.0", 818 "version": "1.0.0",
...@@ -1058,6 +1146,25 @@ ...@@ -1058,6 +1146,25 @@
1058 "url": "https://github.com/sponsors/sindresorhus" 1146 "url": "https://github.com/sponsors/sindresorhus"
1059 } 1147 }
1060 }, 1148 },
1149 + "node_modules/mime-db": {
1150 + "version": "1.52.0",
1151 + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
1152 + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
1153 + "engines": {
1154 + "node": ">= 0.6"
1155 + }
1156 + },
1157 + "node_modules/mime-types": {
1158 + "version": "2.1.35",
1159 + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
1160 + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
1161 + "dependencies": {
1162 + "mime-db": "1.52.0"
1163 + },
1164 + "engines": {
1165 + "node": ">= 0.6"
1166 + }
1167 + },
1061 "node_modules/minimatch": { 1168 "node_modules/minimatch": {
1062 "version": "5.0.1", 1169 "version": "5.0.1",
1063 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", 1170 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
...@@ -1757,6 +1864,17 @@ ...@@ -1757,6 +1864,17 @@
1757 "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", 1864 "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz",
1758 "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", 1865 "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==",
1759 "dev": true 1866 "dev": true
1867 +<<<<<<< HEAD
1868 +=======
1869 + },
1870 + "@types/axios": {
1871 + "version": "0.14.0",
1872 + "resolved": "https://registry.npmjs.org/@types/axios/-/axios-0.14.0.tgz",
1873 + "integrity": "sha512-KqQnQbdYE54D7oa/UmYVMZKq7CO4l8DEENzOKc4aBRwxCXSlJXGz83flFx5L7AWrOQnmuN3kVsRdt+GZPPjiVQ==",
1874 + "requires": {
1875 + "axios": "*"
1876 + }
1877 +>>>>>>> weather
1760 }, 1878 },
1761 "@types/node": { 1879 "@types/node": {
1762 "version": "17.0.35", 1880 "version": "17.0.35",
...@@ -1841,6 +1959,20 @@ ...@@ -1841,6 +1959,20 @@
1841 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", 1959 "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
1842 "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" 1960 "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
1843 }, 1961 },
1962 + "asynckit": {
1963 + "version": "0.4.0",
1964 + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
1965 + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
1966 + },
1967 + "axios": {
1968 + "version": "0.27.2",
1969 + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz",
1970 + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==",
1971 + "requires": {
1972 + "follow-redirects": "^1.14.9",
1973 + "form-data": "^4.0.0"
1974 + }
1975 + },
1844 "balanced-match": { 1976 "balanced-match": {
1845 "version": "1.0.2", 1977 "version": "1.0.2",
1846 "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 1978 "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
...@@ -1940,6 +2072,14 @@ ...@@ -1940,6 +2072,14 @@
1940 "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", 2072 "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
1941 "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" 2073 "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
1942 }, 2074 },
2075 + "combined-stream": {
2076 + "version": "1.0.8",
2077 + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
2078 + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
2079 + "requires": {
2080 + "delayed-stream": "~1.0.0"
2081 + }
2082 + },
1943 "concat-map": { 2083 "concat-map": {
1944 "version": "0.0.1", 2084 "version": "0.0.1",
1945 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 2085 "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
...@@ -1986,6 +2126,14 @@ ...@@ -1986,6 +2126,14 @@
1986 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", 2126 "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
1987 "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", 2127 "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==",
1988 "dev": true 2128 "dev": true
2129 +<<<<<<< HEAD
2130 +=======
2131 + },
2132 + "delayed-stream": {
2133 + "version": "1.0.0",
2134 + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
2135 + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
2136 +>>>>>>> weather
1989 }, 2137 },
1990 "diff": { 2138 "diff": {
1991 "version": "5.0.0", 2139 "version": "5.0.0",
...@@ -2227,6 +2375,24 @@ ...@@ -2227,6 +2375,24 @@
2227 "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz", 2375 "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.5.tgz",
2228 "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", 2376 "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==",
2229 "dev": true 2377 "dev": true
2378 +<<<<<<< HEAD
2379 +=======
2380 + },
2381 + "follow-redirects": {
2382 + "version": "1.15.0",
2383 + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz",
2384 + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ=="
2385 + },
2386 + "form-data": {
2387 + "version": "4.0.0",
2388 + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
2389 + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
2390 + "requires": {
2391 + "asynckit": "^0.4.0",
2392 + "combined-stream": "^1.0.8",
2393 + "mime-types": "^2.1.12"
2394 + }
2395 +>>>>>>> weather
2230 }, 2396 },
2231 "fs.realpath": { 2397 "fs.realpath": {
2232 "version": "1.0.0", 2398 "version": "1.0.0",
...@@ -2474,6 +2640,19 @@ ...@@ -2474,6 +2640,19 @@
2474 "is-unicode-supported": "^0.1.0" 2640 "is-unicode-supported": "^0.1.0"
2475 } 2641 }
2476 }, 2642 },
2643 + "mime-db": {
2644 + "version": "1.52.0",
2645 + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
2646 + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg=="
2647 + },
2648 + "mime-types": {
2649 + "version": "2.1.35",
2650 + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
2651 + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
2652 + "requires": {
2653 + "mime-db": "1.52.0"
2654 + }
2655 + },
2477 "minimatch": { 2656 "minimatch": {
2478 "version": "5.0.1", 2657 "version": "5.0.1",
2479 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", 2658 "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
......
...@@ -13,7 +13,12 @@ ...@@ -13,7 +13,12 @@
13 "author": "", 13 "author": "",
14 "license": "", 14 "license": "",
15 "dependencies": { 15 "dependencies": {
16 + "@types/axios": "^0.14.0",
16 "@types/selenium-webdriver": "^4.1.0", 17 "@types/selenium-webdriver": "^4.1.0",
18 +<<<<<<< HEAD
19 +=======
20 + "axios": "^0.27.2",
21 +>>>>>>> weather
17 "mocha": "^10.0.0", 22 "mocha": "^10.0.0",
18 "selenium-webdriver": "^4.1.2" 23 "selenium-webdriver": "^4.1.2"
19 }, 24 },
......
1 +import * as mocha from 'mocha'
2 +import * as weater from '../weather.js'
3 +
4 +mocha.describe('weather', () => {
5 + mocha.it('get tomorrow weather', async () => {
6 + weater.get_weather_forecast(new Date())
7 + .then(it => console.log(it))
8 + .catch(it => console.log(it))
9 + })
10 +
11 + mocha.it('get 7 days later weather', async () => {
12 + const date = new Date()
13 + date.setDate(new Date().getDate() + 7)
14 +
15 + weater.get_weather_forecast(date)
16 + .then(it => console.log(it))
17 + .catch(it => console.log(it))
18 + })
19 +});
...\ No newline at end of file ...\ No newline at end of file
1 +//@ts-check
2 +/* eslint-disable no-unused-vars */
3 +import * as axios from 'axios';
4 +
5 +
6 +// 최대 7 일간 예보를 반환합니다. 경희대 국제캠퍼스 정문 앞 삼거리 기준으로 호출됩니다.
7 +// 5/27일에 호출했을 경우 6/3일까지의 정오 (한국표준시 기준) 결과를 반환할 수 있습니다.
8 +// 정오 기준, 가장 가까운 날짜의 예보를 반환합니다.
9 +// 예) 호출한 날짜로부터 한 달 뒤 호출 => 호출한 날짜로부터 일주일 뒤 날짜 반환 (최대가 일주일이므로)
10 +// 예) 6/2일 오후 4시 호출 => 6/2일 정오 날씨 반환 (정오 기준이므로)
11 +// 온도의 경우 단위는 섭씨입니다.
12 +
13 +/*example
14 +
15 + "dt": 1653620400,
16 + "sunrise": 1653596132,
17 + "sunset": 1653648142,
18 + "moonrise": 1653589560,
19 + "moonset": 1653637140,
20 + "moon_phase": 0.9,
21 + "temp": {
22 + "day": 21.75,
23 + "min": 15.7,
24 + "max": 22.85,
25 + "night": 16.88,
26 + "eve": 21.29,
27 + "morn": 15.7
28 + },
29 + "feels_like": {
30 + "day": 21.13,
31 + "night": 16.35,
32 + "eve": 20.57,
33 + "morn": 15.41
34 + },
35 + "pressure": 1001,
36 + "humidity": 44,
37 + "dew_point": 8.88,
38 + "wind_speed": 5.88,
39 + "wind_deg": 273,
40 + "wind_gust": 12.32,
41 + "weather": [
42 + {
43 + "id": 500,
44 + "main": "Rain",
45 + "description": "light rain",
46 + "icon": "10d"
47 + }
48 + ],
49 + "clouds": 9,
50 + "pop": 0.2, //Probability of precipitation. The values of the parameter vary between 0 and 1, where 0 is equal to 0%, 1 is equal to 100%
51 + "rain": 0.13, //Precipitation volume, mm
52 + "uvi": 7.71 //The maximum value of UV index for the day
53 +
54 +*/
55 +export async function get_weather_forecast(date) {
56 + const lat = 37.24764302276268 //위도
57 + const lon = 127.0783992268606 //경도
58 + const api_key = "336ddd01d3d6f78782eed90d3921bc7e"
59 +
60 + const target = `https://api.openweathermap.org/data/2.5/onecall?lat=${lat}&lon=${lon}&exclude=minutely,hourly,alerts&appid=${api_key}&units=metric`
61 +
62 + return await axios.default.get(target).then(it => { return extract_from(date, it.data) })
63 +}
64 +
65 +function extract_from(date, json_response) {
66 + const target_timestamp = Math.floor(date.getTime() / 1000)
67 +
68 + const target_index = find_min_index(json_response.daily.map(it => Math.abs(it.dt - target_timestamp)))
69 +
70 + return json_response.daily[target_index]
71 +}
72 +
73 +function find_min_index(array) {
74 + let lowest_index = 0
75 + for (var i = 0; i < array.length; i++) {
76 + if (array[lowest_index] > array[i]) {
77 + lowest_index = i
78 + }
79 + }
80 +
81 + return lowest_index
82 +}
...\ No newline at end of file ...\ No newline at end of file