forked from airheartdev/duffel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsegment.go
39 lines (30 loc) · 855 Bytes
/
segment.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
package duffel
import "time"
func (f *Segment) DepartingAt() (time.Time, error) {
loc, err := time.LoadLocation(f.Origin.TimeZone)
if err != nil {
return time.Time{}, err
}
t, err := time.ParseInLocation("2006-01-02T15:04:05", f.RawDepartingAt, loc)
if err != nil {
return time.Time{}, err
}
return t, err
}
func (f *Segment) ArrivingAt() (time.Time, error) {
loc, err := time.LoadLocation(f.Destination.TimeZone)
if err != nil {
return time.Time{}, err
}
t, err := time.ParseInLocation("2006-01-02T15:04:05", f.RawArrivingAt, loc)
if err != nil {
return time.Time{}, err
}
return t, err
}
func (s SegmentStop) DepartingAt() (time.Time, error) {
return time.Parse("2006-01-02T15:04:05", s.RawDepartingAt)
}
func (s SegmentStop) ArrivingAt() (time.Time, error) {
return time.Parse("2006-01-02T15:04:05", s.RawArrivingAt)
}