package dev.ulfrx.recipe.ui.components.calendar

import androidx.compose.runtime.Composable
import kotlinx.datetime.LocalDate
import kotlinx.datetime.daysUntil
import org.jetbrains.compose.resources.stringResource
import recipe.composeapp.generated.resources.Res
import recipe.composeapp.generated.resources.calendar_horizon_days
import recipe.composeapp.generated.resources.calendar_horizon_today

@Composable
fun horizonLabel(
    today: LocalDate,
    end: LocalDate,
): String {
    val days = (today.daysUntil(end) + 1).coerceAtLeast(1)
    return if (days == 1) {
        stringResource(Res.string.calendar_horizon_today)
    } else {
        stringResource(Res.string.calendar_horizon_days, days)
    }
}
