From 98f4d6c17dc12e47d53dfdf5a067c7f085d5df67 Mon Sep 17 00:00:00 2001 From: jun <134025007+aPPbARRRR@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:53:41 +0900 Subject: [PATCH] =?UTF-8?q?=EB=94=94=EB=B2=84=EA=B9=85=EA=B3=BC=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/dart_debug.dart | 46 ++++++++++++++++ lib/dart_debug_sample.dart | 95 ++------------------------------ lib/test.dart | 15 +++++ test/dart_debug_sample_test.dart | 2 - 4 files changed, 66 insertions(+), 92 deletions(-) create mode 100644 lib/dart_debug.dart create mode 100644 lib/test.dart diff --git a/lib/dart_debug.dart b/lib/dart_debug.dart new file mode 100644 index 0000000..16e0c8e --- /dev/null +++ b/lib/dart_debug.dart @@ -0,0 +1,46 @@ +class YukymController { + YukymTimeModel yukyTimeModel = YukymTimeModel(); + + String getTyA() => '경오${(DateTime.now().month ~/ 2).toString()}국'; + + String getTyB() => + yukyTimeModel.toMap()['ty${(DateTime.now().hour ~/ 2) + 1}']; +} + +class YukymTimeModel { + String ty1 = '갑자1국'; + String ty2 = '갑자2국'; + String ty3 = '갑자3국'; + String ty4 = '갑자4국'; + String ty5 = '갑자5국'; + String ty6 = '갑자6국'; + String ty7 = '갑자7국'; + String ty8 = '갑자8국'; + String ty9 = '갑자9국'; + String ty10 = '갑자10국'; + String ty11 = '갑자11국'; + String ty12 = '갑자12국'; + + Map toMap() { + return { + 'ty1': ty1, + 'ty2': ty2, + 'ty3': ty3, + 'ty4': ty4, + 'ty5': ty5, + 'ty6': ty6, + 'ty7': ty7, + 'ty8': ty8, + 'ty9': ty9, + 'ty10': ty10, + 'ty11': ty11, + 'ty12': ty12, + }; + } +} + +void main() { + YukymController controller = YukymController(); + print(controller.getTyA()); + print(controller.getTyB()); +} diff --git a/lib/dart_debug_sample.dart b/lib/dart_debug_sample.dart index 5472e58..2157c14 100644 --- a/lib/dart_debug_sample.dart +++ b/lib/dart_debug_sample.dart @@ -1,92 +1,7 @@ -import 'package:intl/intl.dart'; +import 'package:dart_debug_sample/dart_debug.dart'; -class YukymController { - - // DateTime.parse(_userData.value!.selectDate) - String nowDate = DateFormat('yyyy-mm-dd').format(DateTime.now()); - - late String nowTime; - - // 1. 자시의 국 : 갑자1국 = getTyOne()의 값 - String getTyA() { - 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; - } else { - // Handle the case when the list is empty - return '경오7국'; // Or any other appropriate action - } - } - - String getTyB() { - 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; - } - - List _getTimeDataOne(String nowDate) { - List timeDataOne = []; - for (int i = 0; i < 24; i++) { - timeDataOne.add(YukymTimeModel()); - } - return timeDataOne; - } +void main() { + YukymController yukymController = YukymController(); + print(yukymController.getTyA()); // 해당 월에 맞는 자시의 국 표시 + print(yukymController.getTyB()); // 해당 시간에 맞는 자시의 국 표시 } - -class YukymTimeModel { - String ty1 = '갑자1국'; - String ty2 = '갑자2국'; - String ty3 = '갑자3국'; - String ty4 = '갑자4국'; - String ty5 = '갑자5국'; - String ty6 = '갑자6국'; - String ty7 = '갑자7국'; - String ty8 = '갑자8국'; - String ty9 = '갑자9국'; - String ty10 = '갑자10국'; - String ty11 = '갑자11국'; - String ty12 = '갑자12국'; -} \ No newline at end of file diff --git a/lib/test.dart b/lib/test.dart new file mode 100644 index 0000000..7f338c4 --- /dev/null +++ b/lib/test.dart @@ -0,0 +1,15 @@ +import 'package:dart_debug_sample/dart_debug.dart'; + +void main() { + + YukymController controller = YukymController(); + + print(controller.getTyA()); + +// print(controller.getTyB()); + + + +} + + diff --git a/test/dart_debug_sample_test.dart b/test/dart_debug_sample_test.dart index 71efb52..d1565bc 100644 --- a/test/dart_debug_sample_test.dart +++ b/test/dart_debug_sample_test.dart @@ -2,7 +2,5 @@ import 'package:dart_debug_sample/dart_debug_sample.dart'; import 'package:test/test.dart'; void main() { - test('', () { - }); }