UtcOffset

The time shift between a local time and UTC.

To ensure that the offset is within the valid supported range, you must explicitly call validate or validated.

inline class UtcOffset(totalSeconds: IntSeconds) : Comparable<UtcOffset>

See also

validate
Link copied to clipboard

validated
Link copied to clipboard

Parameters

totalSeconds

the total number of seconds to offset by

Constructors

UtcOffset
Link copied to clipboard
common

the total number of seconds to offset by

fun UtcOffset(totalSeconds: IntSeconds)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

compareTo
Link copied to clipboard
common
open operator override fun compareTo(other: UtcOffset): Int
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
isZero
Link copied to clipboard
common

Checks if this is the UTC offset of +00:00.

fun isZero(): Boolean
toComponents
Link copied to clipboard
common

Breaks a UTC offset down into components. The sign will indicate whether the offset is positive or negative while each component will be positive.

inline fun <T> toComponents(action: (Int, IntHours, IntMinutes, IntSeconds) -> T): T

Breaks a UTC offset down into components. If the offset is negative, each component will be negative.

inline fun <T> toComponents(action: (IntHours, IntMinutes, IntSeconds) -> T): T
toString
Link copied to clipboard
common

Converts this offset to a string in ISO-8601 extended format. For example, -04:00 or Z.

open override fun toString(): String
validate
Link copied to clipboard
common

Checks if the offset is valid and throws an exception if it isn't.

fun validate()
validated
Link copied to clipboard
common

Ensures that the offset is valid, throwing an exception if it isn't.

fun validated(): UtcOffset

Properties

isValid
Link copied to clipboard
common

Checks if this offset is within the supported range.

val isValid: Boolean
totalSeconds
Link copied to clipboard
common

the total number of seconds to offset by

val totalSeconds: IntSeconds

Extensions

asTimeZone
Link copied to clipboard
common

Converts this UtcOffset into a fixed-offset TimeZone.

fun UtcOffset.asTimeZone(): TimeZone
toJavaZoneOffset
Link copied to clipboard

Converts this UTC offset to an equivalent Java ZoneOffset.

fun UtcOffset.toJavaZoneOffset(): ZoneOffset
toNSTimeZone
Link copied to clipboard
darwin

Converts this offset into an equivalent NSTimeZone with a fixed UTC offset.

Note that NSTimeZonewill round the totalSeconds value to the nearest minute.

fun UtcOffset.toNSTimeZone(): <ERROR CLASS>