Skip to content

Commit

Permalink
Merge pull request #311 from jhoule86/patch-1
Browse files Browse the repository at this point in the history
truncate timezone ID only if it is too long
  • Loading branch information
crc-32 authored Feb 9, 2025
2 parents f1c4bd9 + a05d79f commit 5ed8afa
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -162,4 +169,4 @@ class SystemHandler(
}

expect fun platformTimeChangedFlow(context: PlatformContext): Flow<Unit>
expect fun getPlatformPebbleFlags(context: PlatformContext): Set<PhoneAppVersion.PlatformFlag>
expect fun getPlatformPebbleFlags(context: PlatformContext): Set<PhoneAppVersion.PlatformFlag>

0 comments on commit 5ed8afa

Please sign in to comment.