@@ -12,7 +12,11 @@ import (
1212
1313const dateLayout = "2006-01-02"
1414
15- // DateRange is an inclusive [Start, End] window in UTC.
15+ // DateRange is an inclusive [Start, End] window. Only the calendar date
16+ // (YYYY-MM-DD) of each endpoint is sent to Cronometer's export endpoints,
17+ // so the time-of-day and zone on these values don't round-trip — but the
18+ // calendar date is resolved in the user's local zone so that --today
19+ // matches the day the user sees in the Cronometer UI.
1620type DateRange struct {
1721 Start time.Time
1822 End time.Time
@@ -29,17 +33,18 @@ func AddDateRangeFlags(cmd *cobra.Command) {
2933
3034// ParseDateRangeFromFlags reads the date-range flags off cmd and resolves
3135// them into a concrete DateRange. Default when no flags are passed: the
32- // last 7 days ending today (UTC) .
36+ // last 7 days ending today. "Today" is the user's local calendar day .
3337func ParseDateRangeFromFlags (cmd * cobra.Command ) (DateRange , error ) {
3438 startStr , _ := cmd .Flags ().GetString ("start" )
3539 endStr , _ := cmd .Flags ().GetString ("end" )
3640 days , _ := cmd .Flags ().GetInt ("days" )
3741 today , _ := cmd .Flags ().GetBool ("today" )
38- return resolveDateRange (startStr , endStr , days , today , time .Now (). UTC () )
42+ return resolveDateRange (startStr , endStr , days , today , time .Now ())
3943}
4044
4145func resolveDateRange (startStr , endStr string , days int , today bool , ref time.Time ) (DateRange , error ) {
42- now := ref .Truncate (24 * time .Hour )
46+ y , m , d := ref .Date ()
47+ now := time .Date (y , m , d , 0 , 0 , 0 , 0 , ref .Location ())
4348 var start , end time.Time
4449
4550 switch {
0 commit comments