-
Notifications
You must be signed in to change notification settings - Fork 0
/
datetime.go
135 lines (103 loc) · 2.55 KB
/
datetime.go
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package entities
import (
"database/sql/driver"
"time"
"github.com/jfk9w-go/tinkoff-api"
"github.com/pkg/errors"
)
type Milliseconds struct {
tinkoff.Milliseconds
}
func (ms Milliseconds) GormDataType() string {
return "time"
}
func (ms Milliseconds) Value() (driver.Value, error) {
return ms.Time(), nil
}
func (ms *Milliseconds) Scan(value any) error {
if value, ok := value.(time.Time); ok {
ms.Milliseconds = tinkoff.Milliseconds(value)
return nil
}
return errors.Errorf("expected time.Time, got %T", value)
}
type ReceiptDateTime struct {
tinkoff.ReceiptDateTime
}
func (dt ReceiptDateTime) GormDataType() string {
return "time"
}
func (dt ReceiptDateTime) Value() (driver.Value, error) {
return dt.Time(), nil
}
func (dt *ReceiptDateTime) Scan(value any) error {
if value, ok := value.(time.Time); ok {
dt.ReceiptDateTime = tinkoff.ReceiptDateTime(value)
return nil
}
return errors.Errorf("expected time.Time, got %T", value)
}
type DateTimeMilliOffset struct {
tinkoff.DateTimeMilliOffset
}
func (dt DateTimeMilliOffset) GormDataType() string {
return "time"
}
func (dt DateTimeMilliOffset) Value() (driver.Value, error) {
return dt.Time(), nil
}
func (dt *DateTimeMilliOffset) Scan(value any) error {
if value, ok := value.(time.Time); ok {
dt.DateTimeMilliOffset = tinkoff.DateTimeMilliOffset(value)
return nil
}
return errors.Errorf("expected time.Time, got %T", value)
}
type DateTime struct {
tinkoff.DateTime
}
func (dt DateTime) GormDataType() string {
return "time"
}
func (dt DateTime) Value() (driver.Value, error) {
return dt.Time(), nil
}
func (dt *DateTime) Scan(value any) error {
if value, ok := value.(time.Time); ok {
dt.DateTime = tinkoff.DateTime(value)
return nil
}
return errors.Errorf("expected time.Time, got %T", value)
}
type Date struct {
tinkoff.Date
}
func (d Date) GormDataType() string {
return "date"
}
func (d Date) Value() (driver.Value, error) {
return d.Time(), nil
}
func (d *Date) Scan(value any) error {
if value, ok := value.(time.Time); ok {
d.Date = tinkoff.Date(value)
return nil
}
return errors.Errorf("expected time.Time, got %T", value)
}
type InvestCandleDate struct {
tinkoff.InvestCandleDate
}
func (d InvestCandleDate) GormDataType() string {
return "time"
}
func (d InvestCandleDate) Value() (driver.Value, error) {
return d.Time(), nil
}
func (d *InvestCandleDate) Scan(value any) error {
if value, ok := value.(time.Time); ok {
d.InvestCandleDate = tinkoff.InvestCandleDate(value)
return nil
}
return errors.Errorf("expected time.Time, got %T", value)
}