summaryrefslogtreecommitdiff
path: root/issues/010-fix-quick-add-timestamp.md
blob: 3c593255e01483e49a19ac83669a701fc778cc06 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# [BUG] Quick add date defaults to tomorrow in evening

## Description
The date pre-filled in quick add defaults to tomorrow when used during the evening.

## Symptom
When adding a task in the evening, the date field pre-fills with tomorrow's date instead of today.

## Technical Context
- Likely a timezone or date boundary issue
- Server may be using UTC while user expects local time
- Or JavaScript date handling crossing midnight boundary incorrectly

## Test Strategy

### Unit Test (Red)
**File:** `internal/handlers/handlers_test.go`

```go
func TestQuickAddDefaultDate(t *testing.T) {
    tests := []struct {
        name        string
        serverTime  time.Time
        userTZ      string
        expectedDate string
    }{
        {
            name:        "evening in US Eastern",
            serverTime:  time.Date(2026, 1, 21, 23, 0, 0, 0, time.UTC), // 6pm ET
            userTZ:      "America/New_York",
            expectedDate: "2026-01-21", // Should be today, not tomorrow
        },
        {
            name:        "late night edge case",
            serverTime:  time.Date(2026, 1, 22, 4, 0, 0, 0, time.UTC), // 11pm ET
            userTZ:      "America/New_York",
            expectedDate: "2026-01-21",
        },
    }
    // ...
}
```

## Proposed Approach

1. **Identify the source:**
   - Check quick-add handler: how is default date determined?
   - Check template: is date set server-side or client-side JS?
   - Check if using `time.Now()` (server's timezone) vs user's timezone

2. **Likely fix:**
   - If server-side: pass user's timezone preference and convert
   - If client-side: use `new Date()` which uses browser's local time
   - Ensure consistent timezone handling throughout

3. **Verify date calculation:**
   - `today` should be based on user's local date, not UTC date
   - Evening in US Eastern (UTC-5) at 8pm = UTC next day 1am

## Debugging Steps
1. Check current time on server vs browser
2. Inspect what value is sent in quick-add form
3. Check JavaScript date initialization if client-side
4. Check Go `time.Now()` usage if server-side

## Affected Components
- `internal/handlers/handlers.go` (quick-add endpoint/template data)
- `web/templates/partials/` (quick-add form)
- `web/static/` (if JS sets date)
- Potentially user preferences for timezone

## Definition of Done
- [ ] Quick add defaults to user's local today, regardless of time
- [ ] Works correctly in evening hours
- [ ] Works across timezone boundaries
- [ ] Unit test covers evening edge case