mirror of
https://github.com/samsonjs/SwiftTimeZoneLookup.git
synced 2026-03-25 08:25:49 +00:00
fix memory leak and invalid timezone for greek island
This commit is contained in:
parent
b03b9853ce
commit
55f3d6e384
2 changed files with 16 additions and 0 deletions
|
|
@ -63,6 +63,8 @@ public final class SwiftTimeZoneLookup {
|
|||
if safezone >= 0.0055*2 {
|
||||
return result
|
||||
}
|
||||
ZDFreeResults(result)
|
||||
|
||||
guard let result21 = ZDLookup(database21, latitude, longitude, &safezone) else {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -108,6 +110,12 @@ public final class SwiftTimeZoneLookup {
|
|||
|
||||
/// Resolve the timz
|
||||
public func simple(latitude: Float, longitude: Float) -> String? {
|
||||
if (36.2443...36.7389).contains(latitude) && (26.0019...26.7957).contains(longitude) {
|
||||
// Astypalaia island in Greece does not resolve any timezone and would return nil
|
||||
// Reasons unknown, could be an invalid polygon
|
||||
return "Europe/Athens"
|
||||
}
|
||||
|
||||
guard let result = highResLookup(latitude: latitude, longitude: longitude) else {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,13 @@ final class SwiftTimeZoneLookupTests: XCTestCase {
|
|||
// on the border to the netherlands. Requires high resolution lookup
|
||||
XCTAssertEqual(database.simple(latitude: 53.242293, longitude: 7.209253), "Europe/Berlin")
|
||||
XCTAssertEqual(database.simple(latitude: 53.239692, longitude: 7.207879), "Europe/Amsterdam")
|
||||
|
||||
// Astypalaia island in Greece does not resolve any timezone and would return nil
|
||||
// Reasons unknown, could be an invalid polygon
|
||||
XCTAssertEqual(database.simple(latitude: 36.5362, longitude: 26.3396), "Europe/Athens") // Hard coded fix now in code
|
||||
XCTAssertEqual(database.simple(latitude: 36.8370, longitude: 25.8904), "Europe/Athens") // island to the north
|
||||
XCTAssertEqual(database.simple(latitude: 36.3683, longitude: 25.7735), "Europe/Athens") // island to north west
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue