Skip to content

//core/io.islandtime/roundedUpToNearest

roundedUpToNearest

common

fun Time.roundedUpToNearest(increment: Hours): Time

fun OffsetTime.roundedUpToNearest(increment: Hours): OffsetTime

Returns this time, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

common

fun Time.roundedUpToNearest(increment: Minutes): Time

fun OffsetTime.roundedUpToNearest(increment: Minutes): OffsetTime

Returns this time, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

common

fun Time.roundedUpToNearest(increment: Seconds): Time

fun OffsetTime.roundedUpToNearest(increment: Seconds): OffsetTime

Returns this time, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

common

fun Time.roundedUpToNearest(increment: Milliseconds): Time

fun OffsetTime.roundedUpToNearest(increment: Milliseconds): OffsetTime

Returns this time, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun Time.roundedUpToNearest(increment: Microseconds): Time

fun OffsetTime.roundedUpToNearest(increment: Microseconds): OffsetTime

Returns this time, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun Time.roundedUpToNearest(increment: Nanoseconds): Time

fun OffsetTime.roundedUpToNearest(increment: Nanoseconds): OffsetTime

Returns this time, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun DateTime.roundedUpToNearest(increment: Hours): DateTime

fun OffsetDateTime.roundedUpToNearest(increment: Hours): OffsetDateTime

Returns this date-time, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

common

fun DateTime.roundedUpToNearest(increment: Minutes): DateTime

fun OffsetDateTime.roundedUpToNearest(increment: Minutes): OffsetDateTime

Returns this date-time, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

common

fun DateTime.roundedUpToNearest(increment: Seconds): DateTime

fun OffsetDateTime.roundedUpToNearest(increment: Seconds): OffsetDateTime

Returns this date-time, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

common

fun DateTime.roundedUpToNearest(increment: Milliseconds): DateTime

fun OffsetDateTime.roundedUpToNearest(increment: Milliseconds): OffsetDateTime

Returns this date-time, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun DateTime.roundedUpToNearest(increment: Microseconds): DateTime

fun OffsetDateTime.roundedUpToNearest(increment: Microseconds): OffsetDateTime

Returns this date-time, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun DateTime.roundedUpToNearest(increment: Nanoseconds): DateTime

fun OffsetDateTime.roundedUpToNearest(increment: Nanoseconds): OffsetDateTime

Returns this date-time, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun ZonedDateTime.roundedUpToNearest(increment: Hours): ZonedDateTime

Returns this date-time, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

common

fun ZonedDateTime.roundedUpToNearest(increment: Minutes): ZonedDateTime

Returns this date-time, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

common

fun ZonedDateTime.roundedUpToNearest(increment: Seconds): ZonedDateTime

Returns this date-time, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

common

fun ZonedDateTime.roundedUpToNearest(increment: Milliseconds): ZonedDateTime

Returns this date-time, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

common

fun ZonedDateTime.roundedUpToNearest(increment: Microseconds): ZonedDateTime

Returns this date-time, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

common

fun ZonedDateTime.roundedUpToNearest(increment: Nanoseconds): ZonedDateTime

Returns this date-time, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.

Due to daylight savings time transitions, there a few complexities to be aware of. If the new local time falls within a gap (meaning it doesn't exist), it will be adjusted forward by the length of the gap. If it falls within an overlap (meaning the local time exists twice), the offset will be retained if possible. Otherwise, the earlier offset will be used.

common

fun Instant.roundedUpToNearest(increment: Hours): Instant

Returns this instant, rounded up to the nearest hour that satisfies the increment.

The increment must multiply evenly into a 24-hour day.

common

fun Instant.roundedUpToNearest(increment: Minutes): Instant

Returns this instant, rounded up to the nearest minute that satisfies the increment.

The increment must multiply evenly into an hour.

common

fun Instant.roundedUpToNearest(increment: Seconds): Instant

Returns this instant, rounded up to the nearest second that satisfies the increment.

The increment must multiply evenly into a minute.

common

fun Instant.roundedUpToNearest(increment: Milliseconds): Instant

Returns this instant, rounded up to the nearest millisecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun Instant.roundedUpToNearest(increment: Microseconds): Instant

Returns this instant, rounded up to the nearest microsecond that satisfies the increment.

The increment must multiply evenly into a second.

common

fun Instant.roundedUpToNearest(increment: Nanoseconds): Instant

Returns this instant, rounded up to the nearest nanosecond that satisfies the increment.

The increment must multiply evenly into a second.