diff --git a/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt index a5aa83fb..f161fdbd 100644 --- a/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt +++ b/android/shared/src/commonMain/kotlin/io/rebble/cobble/shared/handlers/SystemHandler.kt @@ -122,13 +122,20 @@ class SystemHandler( val timezone = TimeZone.currentSystemDefault() val now = Clock.System.now() val timezoneOffsetMinutes = timezone.offsetAt(now).totalSeconds.seconds.inWholeMinutes - Logging.i("Sending current time to watch: $now, timezone: ${timezone.id} (truncated: ${timezone.id.take(MAX_TIMEZONE_NAME_LENGTH)}), offset: $timezoneOffsetMinutes") + + val normalizedZone = timezone.id + if (normalizedZone.length > MAX_TIMEZONE_NAME_LENGTH) { + normalizedZone = normalizedZone.take(MAX_TIMEZONE_NAME_LENGTH) + Logging.i("Time Zone ${timezone.id} exceeds maximum value length and has been truncated to ${normalizedZone}") + } + val updateTimePacket = TimeMessage.SetUTC( now.epochSeconds.toUInt(), timezoneOffsetMinutes.toShort(), - timezone.id.take(MAX_TIMEZONE_NAME_LENGTH) + normalizedZone ) + Logging.i("Sending current time to watch: $now, timezone: ${normalizedZone}, offset: $timezoneOffsetMinutes") systemService.send(updateTimePacket) } @@ -162,4 +169,4 @@ class SystemHandler( } expect fun platformTimeChangedFlow(context: PlatformContext): Flow -expect fun getPlatformPebbleFlags(context: PlatformContext): Set \ No newline at end of file +expect fun getPlatformPebbleFlags(context: PlatformContext): Set