diff --git a/core/src/main/kotlin/plus/rua/project/LunarCache.kt b/core/src/main/kotlin/plus/rua/project/LunarCache.kt index 5ab13af..9390786 100644 --- a/core/src/main/kotlin/plus/rua/project/LunarCache.kt +++ b/core/src/main/kotlin/plus/rua/project/LunarCache.kt @@ -80,23 +80,25 @@ class LunarCache( // 农历生日:每年正月二十一(tyme4kt 中正月 indexInYear = 0) val isLunarBirthday = lunarMonth.getIndexInYear() == 0 && lunarDay.day == 21 val isBirthday = isSolarBirthday || isLunarBirthday + // 玫瑰日:每年 10 月 16 日 + val isRoseDay = date.month.number == 10 && date.day == 16 // 农历传统节日(仅当天) val lunarFestival = lunarDay.getFestival() if (lunarFestival != null) { - return DayCellInfo(lunarFestival.getName(), true, holidayBadge, lunarMonthName, isBirthday) + return DayCellInfo(lunarFestival.getName(), true, holidayBadge, lunarMonthName, isBirthday, isRoseDay) } // 节气(当天才显示) val termDay = solarDay.getTermDay() if (termDay.getDayIndex() == 0) { - return DayCellInfo(termDay.getSolarTerm().getName(), true, holidayBadge, lunarMonthName, isBirthday) + return DayCellInfo(termDay.getSolarTerm().getName(), true, holidayBadge, lunarMonthName, isBirthday, isRoseDay) } // 公历节日(仅当天) val solarFestival = solarDay.getFestival() if (solarFestival != null) { - return DayCellInfo(solarFestival.getName(), true, holidayBadge, lunarMonthName, isBirthday) + return DayCellInfo(solarFestival.getName(), true, holidayBadge, lunarMonthName, isBirthday, isRoseDay) } // 默认:农历日期 @@ -106,7 +108,7 @@ class LunarCache( } else { name } - return DayCellInfo(text, false, holidayBadge, lunarMonthName, isBirthday) + return DayCellInfo(text, false, holidayBadge, lunarMonthName, isBirthday, isRoseDay) } companion object { @@ -122,11 +124,13 @@ class LunarCache( * @param isAnnotationHighlight 是否为高亮标注(节日/节气) * @param holidayBadge 法定调休角标("班"/"休"/null) * @param isBirthday 是否为生日 + * @param isRoseDay 是否为玫瑰日(每年 10 月 16 日) */ data class DayCellInfo( val annotationText: String, val isAnnotationHighlight: Boolean, val holidayBadge: String?, val lunarMonthName: String? = null, - val isBirthday: Boolean = false + val isBirthday: Boolean = false, + val isRoseDay: Boolean = false ) diff --git a/core/src/test/kotlin/plus/rua/project/LunarCacheRoseDayTest.kt b/core/src/test/kotlin/plus/rua/project/LunarCacheRoseDayTest.kt new file mode 100644 index 0000000..cfc9847 --- /dev/null +++ b/core/src/test/kotlin/plus/rua/project/LunarCacheRoseDayTest.kt @@ -0,0 +1,29 @@ +package plus.rua.project + +import kotlinx.coroutines.test.runTest +import kotlinx.datetime.LocalDate +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test + +class LunarCacheRoseDayTest { + private val cache = LunarCache() + + @Test + fun october16_returnsTrue() = runTest { + val info = cache.getOrCompute(LocalDate(2026, 10, 16)) + assertTrue("10 月 16 日应为玫瑰日", info.isRoseDay) + } + + @Test + fun september16_returnsFalse() = runTest { + val info = cache.getOrCompute(LocalDate(2026, 9, 16)) + assertFalse("非 10 月的 16 日不应为玫瑰日", info.isRoseDay) + } + + @Test + fun regularDate_returnsFalse() = runTest { + val info = cache.getOrCompute(LocalDate(2026, 6, 15)) + assertFalse("普通日期不应为玫瑰日", info.isRoseDay) + } +}