Skip to content

Commit

Permalink
[android] fix the tm_zone access, which is nullable on Android (#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyp authored Nov 21, 2024
1 parent f68fac7 commit 156ab32
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/FoundationEssentials/TimeZone/TimeZone_Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ struct TimeZoneCache : Sendable, ~Copyable {
var lt : tm = tm()
localtime_r(&t, &lt)

if let name = String(validatingUTF8: lt.tm_zone) {
// tm_zone is nullable on Android.
let tm_zone: UnsafePointer<CChar>? = lt.tm_zone
if let tm_zone, let name = String(validatingUTF8: tm_zone) {
if let result = fixed(name) {
return TimeZone(inner: result)
}
Expand Down

0 comments on commit 156ab32

Please sign in to comment.