-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
315 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// NativeTimeFormat.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
@_implementationOnly import graal_api | ||
|
||
class NativeTimeFormat: NativeBox<dxfg_time_format_t> { | ||
deinit { | ||
let thread = currentThread() | ||
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler))) | ||
} | ||
|
||
static func defaultTimeFormat() -> NativeTimeFormat? { | ||
let thread = currentThread() | ||
if let native = try? ErrorCheck.nativeCall(thread, dxfg_TimeFormat_DEFAULT(thread)) { | ||
return NativeTimeFormat(native: native) | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
static func gmtTimeFormat() -> NativeTimeFormat? { | ||
let thread = currentThread() | ||
if let native = try? ErrorCheck.nativeCall(thread, dxfg_TimeFormat_GMT(thread)) { | ||
return NativeTimeFormat(native: native) | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
convenience init(timeZone: NativeTimeZone) throws { | ||
let thread = currentThread() | ||
let timeFormat = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_getInstance(thread, timeZone.native)) | ||
self.init(native: timeFormat) | ||
} | ||
|
||
convenience init(withTimeZone timeFormat: NativeTimeFormat) throws { | ||
let thread = currentThread() | ||
let timeFormat = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_withTimeZone(thread, timeFormat.native)) | ||
self.init(native: timeFormat) | ||
} | ||
|
||
convenience init(withMillis timeFormat: NativeTimeFormat) throws { | ||
let thread = currentThread() | ||
let timeFormat = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_withMillis(thread, timeFormat.native)) | ||
self.init(native: timeFormat) | ||
} | ||
|
||
convenience init(fullIso timeFormat: NativeTimeFormat) throws { | ||
let thread = currentThread() | ||
let timeFormat = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_asFullIso(thread, timeFormat.native)) | ||
self.init(native: timeFormat) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// NativeTimePeriod.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
@_implementationOnly import graal_api | ||
|
||
class NativeTimePeriod: NativeBox<dxfg_time_period_t> { | ||
deinit { | ||
let thread = currentThread() | ||
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler))) | ||
} | ||
|
||
static func zero() -> NativeTimePeriod? { | ||
let thread = currentThread() | ||
if let native = try? ErrorCheck.nativeCall(thread, dxfg_TimePeriod_ZERO(thread)) { | ||
return NativeTimePeriod(native: native) | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
static func unlimited() -> NativeTimePeriod? { | ||
let thread = currentThread() | ||
if let native = try? ErrorCheck.nativeCall(thread, dxfg_TimePeriod_UNLIMITED(thread)) { | ||
return NativeTimePeriod(native: native) | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
convenience init(value: Int64) throws { | ||
let thread = currentThread() | ||
let timePeriod = try ErrorCheck.nativeCall(thread, dxfg_TimePeriod_valueOf(thread, value)) | ||
self.init(native: timePeriod) | ||
} | ||
|
||
convenience init(value: String) throws { | ||
let thread = currentThread() | ||
let timePeriod = try ErrorCheck.nativeCall(thread, dxfg_TimePeriod_valueOf2(thread, value.toCStringRef())) | ||
self.init(native: timePeriod) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// NativeTimeUtil.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
@_implementationOnly import graal_api | ||
|
||
class NativeTimeUtil { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// NativeTimeZone.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
@_implementationOnly import graal_api | ||
|
||
class NativeTimeZone: NativeBox<dxfg_time_zone_t> { | ||
deinit { | ||
let thread = currentThread() | ||
_ = try? ErrorCheck.nativeCall(thread, dxfg_JavaObjectHandler_release(thread, &(native.pointee.handler))) | ||
} | ||
|
||
static func defaultTimeZone() -> NativeTimeZone? { | ||
let thread = currentThread() | ||
if let native = try? ErrorCheck.nativeCall(thread, dxfg_TimeZone_getDefault(thread)) { | ||
return NativeTimeZone(native: native) | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
convenience init(timeZoneID: String) throws { | ||
let thread = currentThread() | ||
let native = try ErrorCheck.nativeCall(thread, dxfg_TimeZone_getTimeZone(thread, timeZoneID.toCStringRef())) | ||
self.init(native: native) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// DXTimeFormat.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
|
||
public class DXTimeFormat { | ||
public static let defaultTimeFormat: DXTimeFormat? = { | ||
if let timeFormat = NativeTimeFormat.defaultTimeFormat() { | ||
return DXTimeFormat(timeFormat: timeFormat) | ||
} else { | ||
return nil | ||
} | ||
}() | ||
|
||
public static let gmtTimeFormat: DXTimeFormat? = { | ||
if let timeFormat = NativeTimeFormat.gmtTimeFormat() { | ||
return DXTimeFormat(timeFormat: timeFormat) | ||
} else { | ||
return nil | ||
} | ||
}() | ||
|
||
private var timeFormat: NativeTimeFormat | ||
|
||
private init(timeFormat: NativeTimeFormat) { | ||
self.timeFormat = timeFormat | ||
} | ||
|
||
public convenience init(timeZone: DXTimeZone) throws { | ||
let timeFormat = try NativeTimeFormat(timeZone: timeZone.timeZone) | ||
self.init(timeFormat: timeFormat) | ||
} | ||
|
||
public convenience init(withTimeZone timeFormat: DXTimeFormat) throws { | ||
let timeFormat = try NativeTimeFormat(withTimeZone: timeFormat.timeFormat) | ||
self.init(timeFormat: timeFormat) | ||
} | ||
|
||
public convenience init(withMillis timeFormat: DXTimeFormat) throws { | ||
let timeFormat = try NativeTimeFormat(withMillis: timeFormat.timeFormat) | ||
self.init(timeFormat: timeFormat) | ||
} | ||
|
||
public convenience init(fullIso timeFormat: DXTimeFormat) throws { | ||
let timeFormat = try NativeTimeFormat(fullIso: timeFormat.timeFormat) | ||
self.init(timeFormat: timeFormat) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// DXTimePeriod.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
|
||
public class DXTimePeriod { | ||
public static let zero: DXTimePeriod? = { | ||
if let timePeriod = NativeTimePeriod.zero() { | ||
return DXTimePeriod(timePeriod: timePeriod) | ||
} else { | ||
return nil | ||
} | ||
}() | ||
|
||
public static let unlimited: DXTimePeriod? = { | ||
if let timePeriod = NativeTimePeriod.unlimited() { | ||
return DXTimePeriod(timePeriod: timePeriod) | ||
} else { | ||
return nil | ||
} | ||
}() | ||
|
||
private var timePeriod: NativeTimePeriod | ||
|
||
private init(timePeriod: NativeTimePeriod) { | ||
self.timePeriod = timePeriod | ||
} | ||
|
||
convenience init(value: Int64) throws { | ||
let timePeriod = try NativeTimePeriod(value: value) | ||
self.init(timePeriod: timePeriod) | ||
} | ||
|
||
convenience init(value: String) throws { | ||
let timePeriod = try NativeTimePeriod(value: value) | ||
self.init(timePeriod: timePeriod) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// | ||
// DXTimeZone.swift | ||
// DXFeedFramework | ||
// | ||
// Created by Aleksey Kosylo on 20.11.23. | ||
// | ||
|
||
import Foundation | ||
|
||
public class DXTimeZone { | ||
public static let defaultTimeZone: DXTimeZone? = { | ||
if let timeZone = NativeTimeZone.defaultTimeZone() { | ||
return DXTimeZone(timeZone: timeZone) | ||
} else { | ||
return nil | ||
} | ||
}() | ||
|
||
internal var timeZone: NativeTimeZone | ||
|
||
private init(timeZone: NativeTimeZone) { | ||
self.timeZone = timeZone | ||
} | ||
|
||
public convenience init(timeZoneID: String) throws { | ||
self.init(timeZone: try NativeTimeZone(timeZoneID: timeZoneID)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,5 +112,5 @@ final class DateTimeParserTest: XCTestCase { | |
minute: 0, | ||
second: 0)) | ||
} | ||
|
||
} |