-
Notifications
You must be signed in to change notification settings - Fork 0
/
workout.go
45 lines (38 loc) · 1.38 KB
/
workout.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
package healthkit
import (
"encoding/xml"
"fmt"
"time"
)
type Workout struct {
XMLName xml.Name `xml:"Workout"`
WorkoutActivityType string `xml:"workoutActivityType,attr"`
Duration string `xml:"duration,attr"`
DurationUnit string `xml:"durationUnit,attr"`
TotalDistance string `xml:"totalDistance,attr"`
TotalDistanceUnit string `xml:"totalDistanceUnit,attr"`
TotalEnergyBurned string `xml:"totalEnergyBurned,attr"`
TotalEnergyBurnedUnit string `xml:"totalEnergyBurnedUnit,attr"`
SourceName string `xml:"sourceName,attr"`
SourceVersion string `xml:"sourceVersion,attr"`
CreationDate string `xml:"creationDate,attr"`
StartDate string `xml:"startDate,attr"`
EndDate string `xml:"endDate,attr"`
MetadataEntry []*MetadataEntry `xml:"MetadataEntry"`
}
func (w *Workout) String() string {
return fmt.Sprint(*w)
}
func (w *Workout) CreationDateTime() time.Time {
t, _ := time.Parse(timeFormat, w.CreationDate)
return t
}
func (w *Workout) StartDateTime() time.Time {
t, _ := time.Parse(timeFormat, w.StartDate)
return t
}
func (w *Workout) EndDateTime() time.Time {
t, _ := time.Parse(timeFormat, w.EndDate)
return t
}
var _ Data = (*Workout)(nil)