inclusive-period-boundaries-and-offset-reset

Installation
SKILL.md

One boundary convention, and an offset that resets

The whole navigator is one function called with a different argument. offset counts periods backwards: 0 is the current one, 1 the one before it.

// adapted
private fun rangeFor(range: DayRange, offset: Int): Pair<LocalDateTime, LocalDateTime> {
    val today = now().date
    val length = range.lengthInDays
    val end = today.minus(DatePeriod(days = offset * length))
    val start = end.minus(DatePeriod(days = length - 1))
    return start.atTime(0, 0) to end.atTime(23, 59, 59)
}

The comparison against the previous period is the same call with offset + 1, which is the entire reason this shape is worth the indirection.

Installs
2
GitHub Stars
35
First Seen
6 days ago
inclusive-period-boundaries-and-offset-reset — maxrave-dev/kotlin-footguns