Skip to content

Commit e05a93d

Browse files
committed
Initialize TimeZone manually (until swiftlang/swift-foundation#1053 is merged)
1 parent 077b676 commit e05a93d

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ jobs:
1717
with:
1818
# disable export because there are currently problems with shared PCH module cache files with multi-module native export
1919
run-export: false
20+
run-local-tests: false
2021

Sources/SkipAndroidBridge/AndroidBridgeToKotlin.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,26 @@ public class AndroidBridgeKotlin {
4545
fatalError("no AndroidContext.shared")
4646
}
4747
#if os(Android)
48+
try setupTimezone()
4849
try setupFileManagerProperties(filesDir: context.filesDir, cacheDir: context.cacheDir)
4950
try installSystemCertificates()
5051
#endif
5152
logger.log("initAndroidBridge done in \(Date.now.timeIntervalSince(start)) applicationSupportDirectory=\(URL.applicationSupportDirectory.path)")
5253
}
5354
}
5455

56+
private func setupTimezone() {
57+
// Until https://github.com/swiftlang/swift-foundation/pull/1053 gets merged
58+
tzset()
59+
var t = time(nil)
60+
var lt : tm = tm()
61+
localtime_r(&t, &lt)
62+
if let zoneptr = lt.tm_zone, let name = String(validatingUTF8: zoneptr) {
63+
//logger.debug("detected timezone: \(name)")
64+
setenv("TZ", name, 0)
65+
}
66+
67+
}
5568

5669
private func setupFileManagerProperties(filesDir: String, cacheDir: String) throws {
5770
// https://github.com/swiftlang/swift-foundation/blob/main/Sources/FoundationEssentials/FileManager/SearchPaths/FileManager%2BXDGSearchPaths.swift#L46
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Configuration file for https://skip.tools project
22
skip:
3-
mode: 'swift'
3+
mode: 'native'
44
bridging: true
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
#skip:
2-
# mode: 'kotlin'
3-
# bridging: true
1+
skip:
2+
mode: 'transpiled'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
skip:
2-
mode: 'kotlin'
2+
mode: 'transpiled'
33
bridging: true

0 commit comments

Comments
 (0)