io.justdevit.kotlin.boost.extension.Instant.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of boost-commons Show documentation
Show all versions of boost-commons Show documentation
Library to boost working with Kotlin/JVM projects.
The newest version!
package io.justdevit.kotlin.boost.extension
import java.time.Instant
import java.time.Instant.now
import java.time.ZoneOffset.UTC
/**
* Checks if this [Instant] is between the given start and end [Instant]s (inclusive).
*
* @param from The start [Instant].
* @param to The end [Instant].
* @return `true` if this [Instant] is between the start and end [Instant]s (inclusive), `false` otherwise.
*/
fun Instant.isBetween(from: Instant, to: Instant) = !isBefore(from) && !isAfter(to)
/**
* Represents the current year as an integer.
*
* This variable dynamically fetches the current year based on the system's UTC time.
*/
val currentYear: Int
get() = now()
.atOffset(UTC)
.toLocalDate()
.year
© 2015 - 2025 Weber Informatics LLC | Privacy Policy