diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index c224ad5..03fcfb7 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index cb276b8..2a2f9e6 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -7,7 +7,7 @@
-
+
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 7dbaad0..a143c3c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,5 +1,5 @@
plugins {
- kotlin("jvm") version "2.0.21"
+ kotlin("jvm") version "2.2.0"
}
group = "com.survivalcoding"
@@ -17,5 +17,5 @@ tasks.test {
useJUnitPlatform()
}
kotlin {
- jvmToolchain(17)
+ jvmToolchain(21)
}
\ No newline at end of file
diff --git a/src/main/kotlin/YukymController.kt b/src/main/kotlin/YukymController.kt
index cd4bba7..f47a1b6 100644
--- a/src/main/kotlin/YukymController.kt
+++ b/src/main/kotlin/YukymController.kt
@@ -5,58 +5,64 @@ import java.time.format.DateTimeFormatter
class YukymController {
- val nowDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-mm-dd"))
+ // nowDate의 mm 값이 이상함
+ // ISO 8601 표준 yyyy-MM-dd'T'HH:mm:ss
+ // 즉, MM이 아닌 mm을 써서 분이 입력된 것
+ val nowDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))
lateinit var nowTime: String
fun getTyA(): String {
- val timeDataOne = _getTimeDataOne(nowDate)
+ val timeDataOne = _getTimeDataOne()
- if (timeDataOne.isNotEmpty()) {
- nowTime = timeDataOne.first().ty1
+ nowTime = timeDataOne.ty1
- val month = nowDate.substring(5, 7)
- return when (month) {
- "01", "02" -> "경오1국"
- "03", "04" -> "경오2국"
- "05", "06" -> "경오3국"
- "07", "08" -> "경오4국"
- "09", "10" -> "경오5국"
- "11", "12" -> "경오6국"
- else -> nowTime
- }
- } else {
- return "경오7국"
+ // nowDate의 month값이 이상해서 항상 else로 처리됨 => "갑자1국"이 리턴됨
+ val month = nowDate.substring(5, 7)
+ return when (month) {
+ "01", "02" -> "경오1국"
+ "03", "04" -> "경오2국"
+ "05", "06" -> "경오3국"
+ "07", "08" -> "경오4국"
+ "09", "10" -> "경오5국"
+ "11", "12" -> "경오6국"
+ else -> nowTime
}
}
fun getTyB(): String {
- val timeDataOne = _getTimeDataOne(nowDate)
- var result = timeDataOne.first().ty12
+ val timeDataOne = _getTimeDataOne()
+ val result = timeDataOne.ty12
val nowTime = LocalDateTime.now()
- when {
- nowTime.hour >= 0 || nowTime.hour < 2 -> return timeDataOne.first().ty1
- nowTime.hour >= 4 || nowTime.hour < 6 -> return timeDataOne.first().ty2
- nowTime.hour >= 6 || nowTime.hour < 8 -> return timeDataOne.first().ty3
- nowTime.hour >= 8 || nowTime.hour < 10 -> return timeDataOne.first().ty4
- nowTime.hour >= 10 || nowTime.hour < 12 -> return timeDataOne.first().ty5
- nowTime.hour >= 12 || nowTime.hour < 14 -> return timeDataOne.first().ty6
- nowTime.hour >= 16 || nowTime.hour < 18 -> return timeDataOne.first().ty7
- nowTime.hour >= 18 || nowTime.hour < 20 -> return timeDataOne.first().ty8
- nowTime.hour >= 20 || nowTime.hour < 22 -> return timeDataOne.first().ty9
- nowTime.hour >= 22 || nowTime.hour < 24 -> return timeDataOne.first().ty10
+ return when (nowTime.hour) {
+ // 시간은 항상 0보다 크거나 같으므로 항상 "갑자1국"이 반환됨
+ // 2~4, 14~16 시간대가 빠져있음
+ in 0 until 2 -> timeDataOne.ty1
+ in 2 until 4 -> timeDataOne.ty2
+ in 4 until 6 -> timeDataOne.ty3
+ in 6 until 8 -> timeDataOne.ty4
+ in 8 until 10 -> timeDataOne.ty5
+ in 10 until 12 -> timeDataOne.ty6
+ in 12 until 14 -> timeDataOne.ty7
+ in 14 until 16 -> timeDataOne.ty8
+ in 16 until 18 -> timeDataOne.ty9
+ in 18 until 20 -> timeDataOne.ty10
+ in 20 until 22 -> timeDataOne.ty11
+ in 22 until 24 -> timeDataOne.ty12
+ else -> result
}
-
- return result
}
- private fun _getTimeDataOne(nowDate: String): List {
- val timeDataOne = mutableListOf()
- for (i in 0..24) {
- timeDataOne.add(YukymTimeModel())
- }
- return timeDataOne
+ // 인자인 nowDate 값을 사용하지 않음
+ // timeDataOne 리스트에 YukymTimeModel의 인스턴스를 25개 넣어서 리턴
+ private fun _getTimeDataOne(): YukymTimeModel {
+// val timeDataOne = mutableListOf()
+// for (i in 0..24) {
+// timeDataOne.add(YukymTimeModel())
+// }
+
+ return YukymTimeModel()
}
}