@@ -13,12 +13,11 @@ import kotlinx.cinterop.*
13
13
import platform.posix.*
14
14
import kotlin.native.concurrent.*
15
15
16
+ internal expect fun getCurrentSystemDefaultTimeZone (): TimeZone
16
17
17
- internal typealias TZIDVar = kotlinx.cinterop.ULongVarOf < kotlinx.datetime.TZID >
18
18
internal typealias TZID = platform.posix.size_t
19
19
internal expect val TZID_INVALID : TZID
20
20
internal expect fun available_zone_ids (): kotlinx.cinterop.CPointer <kotlinx.cinterop.CPointerVar <kotlinx.cinterop.ByteVar >>?
21
- internal expect fun get_system_timezone (id : kotlinx.cinterop.CValuesRef <kotlinx.datetime.TZIDVar /* = kotlinx.cinterop.ULongVarOf<kotlin.ULong> */ >? ): kotlinx.cinterop.CPointer <kotlinx.cinterop.ByteVar /* = kotlinx.cinterop.ByteVarOf < kotlin.Byte > */ > ?
22
21
internal expect fun offset_at_datetime (zone : kotlinx.datetime.TZID /* = kotlin.ULong */ , epoch_sec : platform.posix.int64_t /* = kotlin.Long */ , offset : kotlinx.cinterop.CValuesRef <kotlinx.cinterop.IntVar /* = kotlinx.cinterop.IntVarOf<kotlin.Int> */ >? ): kotlin.Int
23
22
internal expect fun offset_at_instant (zone : kotlinx.datetime.TZID /* = kotlin.ULong */ , epoch_sec : platform.posix.int64_t /* = kotlin.Long */ ): kotlin.Int
24
23
internal expect fun timezone_by_name (zone_name : kotlin.String? ): kotlinx.datetime.TZID /* = kotlin.ULong */
@@ -27,14 +26,7 @@ public actual open class TimeZone internal constructor(private val tzid: TZID, a
27
26
28
27
actual companion object {
29
28
30
- actual fun currentSystemDefault (): TimeZone = memScoped {
31
- val tzid = alloc<TZIDVar >()
32
- val string = get_system_timezone(tzid.ptr)
33
- ? : throw RuntimeException (" Failed to get the system timezone." )
34
- val kotlinString = string.toKString()
35
- free(string)
36
- TimeZone (tzid.value, kotlinString)
37
- }
29
+ actual fun currentSystemDefault (): TimeZone = getCurrentSystemDefaultTimeZone()
38
30
39
31
actual val UTC : TimeZone = ZoneOffset .UTC
40
32
0 commit comments