Hi. How do you guys observe time zone? I found Tim...
# multiplatform
g
Hi. How do you guys observe time zone? I found TimeZone.currentSystemDefault from kotlinx dateTime but this does not provide updates
a
Wow, you live on the border between two timezones? Never heard anyone needing that. You can check that with gps location somehow.
r
Are you asking for something observable that triggers when timezone changes? I don't know if that exists, but you can always build something that polls for it. You could usa a StateFlow, with a coroutine that runs an infinite loop to poll the current timezone and put the latest into the flow, calling
delay
between checks
👍 1
c
Eg. on mobile apps it can be an issue, that when you cross borders/states, you want to update your UI to show the times in the new timezone. But basically any user facing interface can benefit of showing data in the users chosen language/locale and date/time settings
g
my reasoning was that Googles sample app has it and I wanted it as well. Here is Android implementation https://github.com/android/nowinandroid/blob/a0f278663409e205d292ad88d17970de43ba5[…]gle/samples/apps/nowinandroid/core/data/util/TimeZoneMonitor.kt
I guess I will go lazy way and just check timezone at startup. It's just maybe there was a library for it already and I could use...