Skip to content

Commit

Permalink
Introduce UtcOffset.ZERO constant
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-g committed Jul 2, 2021
1 parent 90c0864 commit cadd19f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/common/src/UtcOffset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public expect class UtcOffset {
public val totalSeconds: Int

public companion object {
public val ZERO: UtcOffset
public fun parse(offsetString: String): UtcOffset
}
}
Expand Down
1 change: 1 addition & 0 deletions core/common/test/TimeZoneTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TimeZoneTest {
val utc: FixedOffsetTimeZone = TimeZone.UTC
println(utc)
assertEquals("Z", utc.id)
assertEquals(UtcOffset.ZERO, utc.offset)
assertEquals(0, utc.offset.totalSeconds)
assertEquals(utc.offset, utc.offsetAt(Clock.System.now()))
}
Expand Down
3 changes: 3 additions & 0 deletions core/js/src/UtcOffset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public actual class UtcOffset(internal val zoneOffset: ZoneOffset) {
override fun toString(): String = zoneOffset.toString()

public actual companion object {

public actual val ZERO: UtcOffset = UtcOffset(ZoneOffset.UTC)

public actual fun parse(offsetString: String): UtcOffset = try {
ZoneOffset.of(offsetString).let(::UtcOffset)
} catch (e: Throwable) {
Expand Down
3 changes: 3 additions & 0 deletions core/jvm/src/UtcOffsetJvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public actual class UtcOffset(internal val zoneOffset: ZoneOffset) {
override fun toString(): String = zoneOffset.toString()

public actual companion object {

public actual val ZERO: UtcOffset = UtcOffset(ZoneOffset.UTC)

public actual fun parse(offsetString: String): UtcOffset = try {
ZoneOffset.of(offsetString).let(::UtcOffset)
} catch (e: DateTimeException) {
Expand Down
2 changes: 1 addition & 1 deletion core/native/src/UtcOffset.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public actual class UtcOffset internal constructor(public actual val totalSecond

public actual companion object {

internal val ZERO: UtcOffset = UtcOffset(0)
public actual val ZERO: UtcOffset = UtcOffset(0)

public actual fun parse(offsetString: String): UtcOffset {
if (offsetString == "Z") {
Expand Down

0 comments on commit cadd19f

Please sign in to comment.