Hello everyone! I'm getting confused when getting ...
# kotlinx-datetime
z
Hello everyone! I'm getting confused when getting
UtcOffset
from
TimeZone
. Why does the
TimeZone.offsetAt(instant: Instant)
function need to be passed an
Instant
instance? According to the documentation,
Instant
is time zone independent
m
The utc offset of a given TimeZone varies, think daylight savings.
z
@mbonnin Could you give some examples? I've simplified this function, will this lead to some unexpected bugs?
Copy code
private val instantZero = Instant.fromEpochSeconds(0)
val TimeZone.utcOffset get() = offsetAt(instantZero)

tz.offsetAt(anyInstant)
tz.utcOffset
m
What you're getting is the UtcOffset on Jan 1st 1970 but if you're in Paris, the UtcOffset changes in spring for daylight savings for an example
z
@mbonnin I understand, thanks! ❤️
👍 1