From 4e91d80443693e77348fef7510c9d1adb6c988ac Mon Sep 17 00:00:00 2001 From: mmmkb1 Date: Wed, 19 Jun 2024 16:39:40 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[feat]=20=EB=94=94=EB=B2=84=EA=B9=85=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=9C=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/dart_debug_sample.dart | 56 ++++++++------------------------------ 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/lib/dart_debug_sample.dart b/lib/dart_debug_sample.dart index 5472e58..acdea35 100644 --- a/lib/dart_debug_sample.dart +++ b/lib/dart_debug_sample.dart @@ -1,70 +1,36 @@ import 'package:intl/intl.dart'; class YukymController { - // DateTime.parse(_userData.value!.selectDate) - String nowDate = DateFormat('yyyy-mm-dd').format(DateTime.now()); + String nowDate = DateFormat('yyyy-MM-dd').format(DateTime.now()); late String nowTime; // 1. 자시의 국 : 갑자1국 = getTyOne()의 값 String getTyA() { - List timeDataOne = - _getTimeDataOne(nowDate); + List timeDataOne = _getTimeDataOne(nowDate); if (timeDataOne.isNotEmpty) { nowTime = timeDataOne.first.ty1; final month = nowDate.substring(5, 7); - if (month == '01' || month == '02') { - return '경오1국'; - } else if (month == '03' || month == '04') { - return '경오2국'; - } else if (month == '05' || month == '06') { - return '경오3국'; - } else if (month == '07' || month == '08') { - return '경오4국'; - } else if (month == '09' || month == '10') { - return '경오5국'; - } else if (month == '11' || month == '12') { - return '경오6국'; - } - return nowTime; + int monthNum = int.parse(month); + int regionNum = (monthNum + 1) ~/ 2; + + return (monthNum >= 1 && monthNum <= 12) ? '경오$regionNum국' : nowTime; } else { // Handle the case when the list is empty - return '경오7국'; // Or any other appropriate action + return '경오7국'; // Or any other appropriate action } } String getTyB() { - List timeDataOne = - _getTimeDataOne(nowDate); + List timeDataOne = _getTimeDataOne(nowDate); String result = timeDataOne.first.ty12; final nowTime = DateTime.now(); - if (nowTime.hour >= 0 || nowTime.hour < 2) { - return timeDataOne.first.ty1; - } else if (nowTime.hour >= 4 || nowTime.hour < 6) { - return timeDataOne.first.ty2; - } else if (nowTime.hour >= 6 || nowTime.hour < 8) { - return timeDataOne.first.ty3; - } else if (nowTime.hour >= 8 || nowTime.hour < 10) { - return timeDataOne.first.ty4; - } else if (nowTime.hour >= 10 || nowTime.hour < 12) { - return timeDataOne.first.ty5; - } else if (nowTime.hour >= 12 || nowTime.hour < 14) { - return timeDataOne.first.ty6; - } else if (nowTime.hour >= 16 || nowTime.hour < 18) { - return timeDataOne.first.ty7; - } else if (nowTime.hour >= 18 || nowTime.hour < 20) { - return timeDataOne.first.ty8; - } else if (nowTime.hour >= 20 || nowTime.hour < 22) { - return timeDataOne.first.ty9; - } else if (nowTime.hour >= 22 || nowTime.hour < 24) { - return timeDataOne.first.ty10; - } - - return result; + int regionNum = nowTime.hour ~/ 2 + 1; + return (nowTime.hour >= 0 && nowTime.hour < 24) ? '갑자$regionNum국' : result; } List _getTimeDataOne(String nowDate) { @@ -89,4 +55,4 @@ class YukymTimeModel { String ty10 = '갑자10국'; String ty11 = '갑자11국'; String ty12 = '갑자12국'; -} \ No newline at end of file +} From 92c9c2e5dc42ab7a53e8b41d5ba705de79a1b090 Mon Sep 17 00:00:00 2001 From: mmmkb1 Date: Wed, 19 Jun 2024 16:43:17 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[feat]=20=EB=94=94=EB=B2=84=EA=B9=85=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=95=20=EB=AC=B8=EC=84=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 process.md diff --git a/process.md b/process.md new file mode 100644 index 0000000..e69de29 From 95627395456de2549a581facb633e6c5c95f2a36 Mon Sep 17 00:00:00 2001 From: mmmkb1 Date: Wed, 19 Jun 2024 20:06:59 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[feat]=20=EB=94=94=EB=B2=84=EA=B9=85=20?= =?UTF-8?q?=EA=B3=BC=EC=A0=95=20=EB=AC=B8=EC=84=9C=20=EB=88=84=EB=9D=BD..?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/process.md b/process.md index e69de29..517cc18 100644 --- a/process.md +++ b/process.md @@ -0,0 +1,28 @@ +# 디버깅 과정 +## 프로그램 돌려보기 +1. pub get +2. void main() 실행 +3. console 출력 (현재시간: 2024-06-19 15:30) + 갑자1국 + 갑자1국 + +### 첫번재 에러 발견 +1. getTyA 출력 에러 +2. 브레이크 포인트 활용하여 코드 한 줄씩 확인한다 + yukymController에 적절한 값이 들어오는지 확인한다 + yukymController.nowDate="2024-15-19" 확인 +3. Datetime format에서 mm은 minute, MM은 month를 의미한다 + String nowDate = DateFormat('yyyy-mm-dd').format(DateTime.now()); 를 + String nowDate = DateFormat('yyyy-MM-dd').format(DateTime.now()); 로 수정 +4. getTyA 정상 출력 확인 + +### 두번째 에러 발견 +1. getTyB 출력 에러 +2. 브레이크 포인트 활용하여 코드 한 줄씩 확인한다 +3. nowTime에 적절한 값이 들어오는지 확인한다 + nowTime.hour은 정상적인 값인 것을 확인 +4. nowTime.hour 값을 바꿔도 첫번째 조건문에 해당하는 값을 return한다 +5. 논리식이 잘못됨을 확인하고 || -> &&으로 변경 +6. 아래 조건문이 빠져 있고 YukymTimeModel과 맞지 않아 추가함 + else if (nowTime.hour >= 2 && nowTime.hour < 4) {...} + else if (nowTime.hour >= 14 && nowTime.hour < 16) {...} \ No newline at end of file