Skip to content

Commit 668face

Browse files
committed
fix: use local timezone for date grouping and filtering
1 parent aaedb8a commit 668face

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

cmd/ccost/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func main() {
5757
}
5858

5959
if sinceStr != "" {
60-
t, err := time.Parse("2006-01-02", sinceStr)
60+
t, err := time.ParseInLocation("2006-01-02", sinceStr, time.Local)
6161
if err != nil {
6262
fmt.Fprintf(os.Stderr, "invalid --since date: %v\n", err)
6363
os.Exit(1)
@@ -66,7 +66,7 @@ func main() {
6666
}
6767

6868
if untilStr != "" {
69-
t, err := time.Parse("2006-01-02", untilStr)
69+
t, err := time.ParseInLocation("2006-01-02", untilStr, time.Local)
7070
if err != nil {
7171
fmt.Fprintf(os.Stderr, "invalid --until date: %v\n", err)
7272
os.Exit(1)

internal/parser/parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func parseTime(s string) (time.Time, bool) {
177177
return time.Time{}, false
178178
}
179179
}
180-
return t, true
180+
return t.Local(), true
181181
}
182182

183183
// dayBounds tracks min/max timestamps for a single day.
@@ -289,7 +289,7 @@ func parseFile(path string, opts Options, isMain bool) ([]Record, []Session, []s
289289
var sessions []Session
290290
if isMain && project != "" {
291291
for date, b := range days {
292-
day, _ := time.Parse("2006-01-02", date)
292+
day, _ := time.ParseInLocation("2006-01-02", date, time.Local)
293293
if !opts.Since.IsZero() && day.Before(opts.Since) {
294294
continue
295295
}

0 commit comments

Comments
 (0)