-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtimeinterval.go
More file actions
60 lines (47 loc) · 952 Bytes
/
timeinterval.go
File metadata and controls
60 lines (47 loc) · 952 Bytes
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
package gpass
import (
"time"
"github.com/sonda2208/gpass/walletobjects"
)
type DateTime struct {
Date time.Time
}
func (dt *DateTime) toWO() *walletobjects.DateTime {
return &walletobjects.DateTime{
Date: dt.Date.UTC().Format(time.RFC3339),
}
}
func woToDateTime(dt *walletobjects.DateTime) *DateTime {
if dt == nil {
return nil
}
res, _ := time.Parse(time.RFC3339, dt.Date)
return &DateTime{
Date: res,
}
}
type TimeInterval struct {
Start *DateTime
End *DateTime
}
func (ti *TimeInterval) toWO() *walletobjects.TimeInterval {
res := walletobjects.TimeInterval{
Kind: "walletobjects#timeInterval",
}
if ti.Start != nil {
res.Start = ti.Start.toWO()
}
if ti.End != nil {
res.End = ti.End.toWO()
}
return &res
}
func woToTimeInterval(ti *walletobjects.TimeInterval) *TimeInterval {
if ti == nil {
return nil
}
return &TimeInterval{
Start: woToDateTime(ti.Start),
End: woToDateTime(ti.End),
}
}