|
6 | 6 | * Copyright (c) 2007-present, Stephen Colebourne & Michael Nascimento Santos
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -@file:OptIn(ExperimentalForeignApi::class) |
10 |
| - |
11 | 9 | package kotlinx.datetime
|
12 | 10 |
|
13 |
| -import kotlinx.cinterop.ExperimentalForeignApi |
14 |
| -import kotlinx.cinterop.memScoped |
15 | 11 | import kotlinx.datetime.internal.*
|
16 | 12 | import kotlinx.datetime.serializers.*
|
17 | 13 | import kotlinx.serialization.Serializable
|
@@ -103,48 +99,6 @@ public actual open class TimeZone internal constructor() {
|
103 | 99 | override fun toString(): String = id
|
104 | 100 | }
|
105 | 101 |
|
106 |
| -internal interface TimezoneDatabase { |
107 |
| - fun rulesForId(id: String): TimeZoneRules |
108 |
| - fun availableTimeZoneIds(): Set<String> |
109 |
| -} |
110 |
| - |
111 |
| -internal expect val systemTzdb: TimezoneDatabase |
112 |
| - |
113 |
| -internal expect fun currentSystemDefaultZone(): RegionTimeZone |
114 |
| - |
115 |
| -internal class RegionTimeZone(private val tzid: TimeZoneRules, override val id: String) : TimeZone() { |
116 |
| - |
117 |
| - override fun atStartOfDay(date: LocalDate): Instant = memScoped { |
118 |
| - val ldt = LocalDateTime(date, LocalTime.MIN) |
119 |
| - when (val info = tzid.infoAtDatetime(ldt)) { |
120 |
| - is OffsetInfo.Regular -> ldt.toInstant(info.offset) |
121 |
| - is OffsetInfo.Gap -> info.start |
122 |
| - is OffsetInfo.Overlap -> ldt.toInstant(info.offsetBefore) |
123 |
| - } |
124 |
| - } |
125 |
| - |
126 |
| - override fun atZone(dateTime: LocalDateTime, preferred: UtcOffset?): ZonedDateTime = |
127 |
| - when (val info = tzid.infoAtDatetime(dateTime)) { |
128 |
| - is OffsetInfo.Regular -> ZonedDateTime(dateTime, this, info.offset) |
129 |
| - is OffsetInfo.Gap -> { |
130 |
| - try { |
131 |
| - ZonedDateTime(dateTime.plusSeconds(info.transitionDurationSeconds), this, info.offsetAfter) |
132 |
| - } catch (e: IllegalArgumentException) { |
133 |
| - throw DateTimeArithmeticException( |
134 |
| - "Overflow whet correcting the date-time to not be in the transition gap", |
135 |
| - e |
136 |
| - ) |
137 |
| - } |
138 |
| - } |
139 |
| - |
140 |
| - is OffsetInfo.Overlap -> ZonedDateTime(dateTime, this, |
141 |
| - if (info.offsetAfter == preferred) info.offsetAfter else info.offsetBefore) |
142 |
| - } |
143 |
| - |
144 |
| - override fun offsetAtImpl(instant: Instant): UtcOffset = tzid.infoAtInstant(instant) |
145 |
| -} |
146 |
| - |
147 |
| - |
148 | 102 | @Serializable(with = FixedOffsetTimeZoneSerializer::class)
|
149 | 103 | public actual class FixedOffsetTimeZone internal constructor(public actual val offset: UtcOffset, override val id: String) : TimeZone() {
|
150 | 104 |
|
|
0 commit comments