fix: resolve build errors and implement missing health data types

- Fix various build errors in the CLI application.
- Implement missing health data types (VO2 Max, Heart Rate Zones).
- Corrected `tablewriter` usage from `SetHeader` to `Header`.
- Removed unused imports and fixed syntax errors.
This commit is contained in:
2025-09-19 05:19:02 -07:00
parent 47a179d215
commit c1993ba022
36 changed files with 878 additions and 405 deletions

View File

@@ -2,6 +2,7 @@ package utils
import (
"time"
"strconv"
)
var (
@@ -36,3 +37,29 @@ func ToLocalTime(utcTime time.Time) time.Time {
func ToUTCTime(localTime time.Time) time.Time {
return localTime.UTC()
}
// parseAggregationKey is a helper function to parse aggregation key back to a time.Time object
func ParseAggregationKey(key, aggregate string) time.Time {
switch aggregate {
case "day":
t, _ := time.Parse("2006-01-02", key)
return t
case "week":
year, _ := strconv.Atoi(key[:4])
week, _ := strconv.Atoi(key[6:])
t := time.Date(year, 1, 1, 0, 0, 0, 0, time.UTC)
// Find the first Monday of the year
for t.Weekday() != time.Monday {
t = t.AddDate(0, 0, 1)
}
// Add weeks
return t.AddDate(0, 0, (week-1)*7)
case "month":
t, _ := time.Parse("2006-01", key)
return t
case "year":
t, _ := time.Parse("2006", key)
return t
}
return time.Time{}
}