Skip to content

Commit 9f2a2d4

Browse files
TimeZone.of("z") should work the same as calling from capital "Z" #530 (#530)
Fixes #529
1 parent 2094289 commit 9f2a2d4

File tree

4 files changed

+4
-7
lines changed

4 files changed

+4
-7
lines changed

core/common/test/TimeZoneTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class TimeZoneTest {
111111
Pair("Europe/Paris", "Europe/Paris"),
112112
Pair("Europe/Berlin", "Europe/Berlin"),
113113
Pair("Z", "Z"),
114+
Pair("z", "Z"),
114115
Pair("UTC", "UTC"),
115116
Pair("UTC+01:00", "UTC+01:00"),
116117
Pair("GMT+01:00", "GMT+01:00"),

core/common/test/format/DateTimeComponentsFormatTest.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,7 @@ class DateTimeComponentsFormatTest {
331331

332332
@Test
333333
fun testZuluTimeZone() {
334-
// Replace it to:
335-
// listOf("z", "Z").forEach(::assertParseableAsTimeZone)
336-
// when TimeZone.of("z") works correctly
337-
assertParseableAsTimeZone("Z")
338-
assertIncorrectlyParseableAsTimeZone("z")
334+
listOf("z", "Z").forEach(::assertParseableAsTimeZone)
339335
}
340336

341337
@Test

core/commonKotlin/src/TimeZone.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public actual open class TimeZone internal constructor() {
3232
if (zoneId == "UTC") {
3333
return UTC
3434
}
35-
if (zoneId == "Z") {
35+
if (zoneId == "Z" || zoneId == "z") {
3636
return UtcOffset.ZERO.asTimeZone()
3737
}
3838
if (zoneId == "SYSTEM") {

core/jvm/src/TimeZoneJvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public actual open class TimeZone internal constructor(internal val zoneId: Zone
3636
FixedOffsetTimeZone(UtcOffset.ZERO, ZoneId.of("UTC"))
3737

3838
public actual fun of(zoneId: String): TimeZone = try {
39-
ofZone(ZoneId.of(zoneId))
39+
ofZone(ZoneId.of(if (zoneId == "z") "Z" else zoneId))
4040
} catch (e: Exception) {
4141
if (e is DateTimeException) throw IllegalTimeZoneException(e)
4242
throw e

0 commit comments

Comments
 (0)