All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.MinuteInterval.kt Maven / Gradle / Ivy

There is a newer version: 0.19.0
Show newest version
package com.juul.krayon.time

import kotlinx.datetime.LocalDateTime
import kotlin.time.Duration.Companion.minutes

public object MinuteInterval : Interval, Interval.Count, Interval.Field {

    override fun floor(input: LocalDateTime): LocalDateTime =
        with(input) { LocalDateTime(year, month, dayOfMonth, hour, minute) }

    override fun offset(input: LocalDateTime, steps: Int): LocalDateTime =
        input + steps.minutes

    override fun count(start: LocalDateTime, stop: LocalDateTime): Int =
        (stop - start).inWholeMinutes.coerceToInt()

    override fun field(input: LocalDateTime): Int =
        input.minute
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy