iosArm64Main.common.TimeZone.objc.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluid-time-iosarm64 Show documentation
Show all versions of fluid-time-iosarm64 Show documentation
multiplatform date & time library
The newest version!
package com.github.fluidsonic.fluid.time
import platform.Foundation.*
fun TimeZone.toPlatform() =
platform
actual typealias PlatformTimeZone = NSTimeZone
internal actual fun PlatformTimeZone.daylightSavingTimeOffset(timestamp: Timestamp) =
Seconds(daylightSavingTimeOffsetForDate(timestamp.toPlatform()).toLong())
internal actual val PlatformTimeZone.id: String
get() =
name.let { id ->
if (id == "GMT") "UTC" else id
}
internal actual fun PlatformTimeZone.isDaylightSavingTime(timestamp: Timestamp) =
isDaylightSavingTimeForDate(timestamp.toPlatform())
internal actual fun PlatformTimeZone.nextDaylightSavingTimeTransition(after: Timestamp) =
nextDaylightSavingTimeTransitionAfterDate(after.toPlatform())?.toCommon()
internal actual object PlatformTimeZoneStatic {
@Suppress("UNCHECKED_CAST")
actual val knownTimeZoneIds: Set =
(PlatformTimeZone.knownTimeZoneNames as List).toSet()
actual val systemTimeZoneId: String
get() = PlatformTimeZone.systemTimeZone.id
actual fun timeZoneWithId(id: String) =
PlatformTimeZone.timeZoneWithName(id)
}