Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
kotlin("jvm") version "2.0.21"
kotlin("jvm") version "2.2.0"
}

group = "com.survivalcoding"
Expand All @@ -17,5 +17,5 @@ tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
jvmToolchain(21)
}
80 changes: 43 additions & 37 deletions src/main/kotlin/YukymController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<YukymTimeModel> {
val timeDataOne = mutableListOf<YukymTimeModel>()
for (i in 0..24) {
timeDataOne.add(YukymTimeModel())
}
return timeDataOne
// 인자인 nowDate 값을 사용하지 않음
// timeDataOne 리스트에 YukymTimeModel의 인스턴스를 25개 넣어서 리턴
private fun _getTimeDataOne(): YukymTimeModel {
// val timeDataOne = mutableListOf<YukymTimeModel>()
// for (i in 0..24) {
// timeDataOne.add(YukymTimeModel())
// }

return YukymTimeModel()
}
}

Expand Down