-
Notifications
You must be signed in to change notification settings - Fork 12
/
utils.jl
69 lines (46 loc) · 1.29 KB
/
utils.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function from_ibtime(s)
if length(s) == 17 && s[9] == '-'
ZonedDateTime(DateTime(s, "yyyymmdd-HH:MM:SS"), TimeZones.utc_tz)
elseif length(s) > 20 && s[9] == ' '
tz = validatetz(s[19:end])
ZonedDateTime(DateTime(s[1:17], "yyyymmdd HH:MM:SS"), tz)
else
error("Unknown format $s")
end
end
"""
validatetz(tz)
Try to infer the server time zone setting from the connection
timestamp string.
"""
function validatetz(tz)
if tz ∈ ["UTC", "GMT"]
TimeZones.utc_tz
elseif tz ∈ ["EST", "EDT", "Eastern Standard Time"]
tz"America/New_York"
elseif tz ∈ ["CST", "CDT"]
tz"America/Chicago"
elseif tz ∈ ["PST", "PDT"]
tz"America/Los_Angeles"
elseif tz ∈ ["CET", "CEST", "Central European Time"]
tz"Europe/Paris"
elseif tz ∈ ["BST", "British Summer Time", "Greenwich Mean Time"]
tz"Europe/London"
elseif tz == "JST"
tz"Asia/Tokyo"
elseif tz == "HKT"
tz"Asia/Hong_Kong"
elseif tz == "SGT"
tz"Asia/Singapore"
elseif tz == "China Standard Time"
tz"Asia/Shanghai"
else
error("Unknown TZ: $tz")
end
end
function Base.show(io::IO, x::T) where T<:Union{Contract,ContractDetails,Order,OrderState,ScannerSubscription}
for n ∈ fieldnames(T)
v = getfield(x, n)
println(n, "= ", something(v, "NA"))
end
end