Add X-Timezone header to all API requests

Send the device's IANA timezone identifier (e.g., "America/Los_Angeles")
with every API request to enable timezone-aware overdue task detection.

Platform implementations:
- Android/JVM: TimeZone.getDefault().id
- iOS: NSTimeZone.localTimeZone.name
- JS/WASM: Intl.DateTimeFormat().resolvedOptions().timeZone

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-12-13 00:04:44 -06:00
parent 258ccf7354
commit a3e1c338d2
6 changed files with 37 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ import io.ktor.client.plugins.logging.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.json.Json
import platform.Foundation.NSLocale
import platform.Foundation.NSTimeZone
import platform.Foundation.preferredLanguages
actual fun getLocalhostAddress(): String = "127.0.0.1"
@@ -19,6 +20,10 @@ actual fun getDeviceLanguage(): String {
return firstLanguage?.split("-")?.firstOrNull() ?: "en"
}
actual fun getDeviceTimezone(): String {
return NSTimeZone.localTimeZone.name
}
actual fun createHttpClient(): HttpClient {
return HttpClient(Darwin) {
install(ContentNegotiation) {
@@ -36,6 +41,7 @@ actual fun createHttpClient(): HttpClient {
install(DefaultRequest) {
headers.append("Accept-Language", getDeviceLanguage())
headers.append("X-Timezone", getDeviceTimezone())
}
engine {