diff options
| author | Charlie Root <root@dangofactory.local> | 2026-09-24 08:13:51 +0900 |
|---|---|---|
| committer | Charlie Root <root@dangofactory.local> | 2026-09-24 08:13:51 +0900 |
| commit | da67717a90feb050d53e70848ff403c0ea9b9892 (patch) | |
| tree | 4b39d6f11c20436d333dc946f833556971d7a6b7 /modules | |
| parent | 84b54c9f7b3df2153c434d8491b92056fc350d76 (diff) | |
| download | kukuri-da67717a90feb050d53e70848ff403c0ea9b9892.tar.gz kukuri-da67717a90feb050d53e70848ff403c0ea9b9892.tar.bz2 kukuri-da67717a90feb050d53e70848ff403c0ea9b9892.zip | |
UI calendar: build the current YearMonth from LocalDate.monthNumber so the Android target compiles too
The Wasm-only fix for the calendar's YearMonth was not enough. Two further
problems showed up once the Android target compiled the same code:
1. YearMonth(today.year, today.month) failed type inference on Android:
kotlinx-datetime's Month and com.kizitonwose.calendar.core's Month are
different types.
2. The obvious repair, today.month.number, does not exist either - Month has no
`number` property in kotlinx-datetime 0.7.1.
Take the month as an Int straight off LocalDate instead: today.monthNumber is an
Int property on LocalDate (verified present in the 0.7.1 sources before use),
which sidesteps the Month type mismatch entirely and works on both targets.
Verified with both compilations in one run -
compileDebugKotlinAndroid and compileKotlinWasmJs both pass.
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/FramesCalendarNoteLive.kt | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/FramesCalendarNoteLive.kt b/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/FramesCalendarNoteLive.kt index 9cceb79..c836790 100644 --- a/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/FramesCalendarNoteLive.kt +++ b/modules/orgflow-ui/src/commonMain/kotlin/jp/orgflow/web/FramesCalendarNoteLive.kt @@ -73,16 +73,15 @@ fun CalendarFrame() { /** 月グリッド。予定のある日にドットを出す(§2.22)。 */ @Composable private fun MonthCalendar(onDayClick: (CalendarDay) -> Unit) { - // com.kizitonwose.calendar.core.YearMonth はライブラリ独自の型 - // (kotlinx-datetime 0.6.2 に YearMonth が無いため自前で持っている)。 - // now()/plusMonths()/minusMonths() もライブラリが提供する。 - // YearMonth.now() は Wasm でリンクできない (IrLinkageError: - // com.kizitonwose.calendar.core/YearMonth.Companion.now が - // kotlin.time.Clock を要求するが、この Kotlin バージョンでは - // 解決できない)。LocalDate から組み立てれば同じ値になる。 - val currentMonth = remember { - val today = LocalDate.now() - YearMonth(today.year, today.month) + // YearMonth.now() は使えない: com.kizitonwose.calendar.core の + // YearMonth.Companion.now は kotlin.time.Clock を要求し、この Kotlin 版では + // Wasm でリンクできない (IrLinkageError)。LocalDate から組み立てる。 + // month は数値で渡す: ライブラリの Month enum と kotlinx-datetime の Month は + // 別の型なので、Int を取るコンストラクタを使う。月番号は LocalDate から + // 直接取る(Month 型を経由しない)。 + val currentMonth: YearMonth = remember { + val today: LocalDate = LocalDate.now() + YearMonth(today.year, today.monthNumber) } val startMonth = remember { currentMonth.minusMonths(24) } val endMonth = remember { currentMonth.plusMonths(24) } |
