Skip to content

//core/io.islandtime/roundedUpTo

roundedUpTo

common

fun Time.roundedUpTo(unit: TimeUnit): Time

fun OffsetTime.roundedUpTo(unit: TimeUnit): OffsetTime

Returns this time, rounded up to match the precision of a given unit.

common

fun DateTime.roundedUpTo(unit: TimeUnit): DateTime

fun OffsetDateTime.roundedUpTo(unit: TimeUnit): OffsetDateTime

Returns this date-time, rounded up to match the precision of a given unit.

The start of the next day will be returned when the resulting time is after midnight.

common

fun ZonedDateTime.roundedUpTo(unit: TimeUnit): ZonedDateTime

Returns this date-time, rounded up to match the precision of a given unit.

The start of the next day will be returned when the resulting time is after midnight.

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.roundedUpTo(unit: TimeUnit): Instant

Returns this instant, rounded up to match the precision of a given unit.