-
Notifications
You must be signed in to change notification settings - Fork 0
/
fit-tools.go
41 lines (33 loc) · 943 Bytes
/
fit-tools.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
package main
import (
"fmt"
"time"
"github.com/tormoder/fit"
)
// Lap contains beginning and end second for the given lap
type Lap struct {
Beginning time.Time
End time.Time
}
// InternalActivity is a file-independent representation of a cyling activity
type InternalActivity struct {
Laps []Lap
}
// ConvertToInternalActivity converts from a FIT activity to a InternalActivity
func convertToInternalActivity(fitActivty *fit.ActivityFile) *InternalActivity {
internalActivity := InternalActivity{
Laps: make([]Lap, 0, len(fitActivty.Laps)),
}
for _, fitLap := range fitActivty.Laps {
lap := Lap{
Beginning: fitLap.StartTime,
End: fitLap.StartTime.Add(time.Second * time.Duration(fitLap.TotalElapsedTime)),
}
internalActivity.Laps = append(internalActivity.Laps, lap)
}
return &internalActivity
}
// TryToGetThisToWork prints struff
func TryToGetThisToWork() {
fmt.Println("From separate file!")
}