Summary
The usage tab displays usage data grouped by UTC dates instead of the user's local timezone. This affects both "By Day" and "By Model & Day" views, as well as the streak calculation and streak calendar.
Affected Components
- Usage tab "By Day" view
- Usage tab "By Model & Day" view
- Streak calculation
- Streak calendar
Problem
When viewing usage data, dates are grouped by UTC day rather than the user's local day. For example, a user in PST (UTC-8) coding at 8 PM will have their usage recorded as occurring on the next day in UTC.
Possible root cause: The API route /api/profile/usage/route.ts uses DATE(created_at) which extracts the date in the database's timezone (UTC), and the streak calculation uses JavaScript's toISOString() which always returns UTC.
Steps to Reproduce
- Set browser timezone to a non-UTC timezone (e.g., PST, EST)
- Navigate to the usage tab
- View "By Day" or "By Model & Day" view
- Observe that dates shown don't match local date boundaries
Expected Behavior
- Usage data should be grouped by the user's local date
- Streak calculation should count consecutive days in the user's local timezone
- Streak calendar should display dates in the user's local timezone
Actual Behavior
- Usage data is grouped by UTC date
- Streak calculation uses UTC-based date comparison
- Dates displayed don't match user's local date boundaries
Possible Root Causes
- API route uses
DATE(created_at) PostgreSQL function without timezone conversion
- Client-side streak calculation uses
toISOString().split('T')[0] which is UTC-based
- Browser timezone is not detected or passed to the API
Environment
- Component: Usage tab (
/app/(app)/usage/page.tsx)
- API:
/api/profile/usage/route.ts
- Database: PostgreSQL with
microdollar_usage table
Summary
The usage tab displays usage data grouped by UTC dates instead of the user's local timezone. This affects both "By Day" and "By Model & Day" views, as well as the streak calculation and streak calendar.
Affected Components
Problem
When viewing usage data, dates are grouped by UTC day rather than the user's local day. For example, a user in PST (UTC-8) coding at 8 PM will have their usage recorded as occurring on the next day in UTC.
Possible root cause: The API route
/api/profile/usage/route.tsusesDATE(created_at)which extracts the date in the database's timezone (UTC), and the streak calculation uses JavaScript'stoISOString()which always returns UTC.Steps to Reproduce
Expected Behavior
Actual Behavior
Possible Root Causes
DATE(created_at)PostgreSQL function without timezone conversiontoISOString().split('T')[0]which is UTC-basedEnvironment
/app/(app)/usage/page.tsx)/api/profile/usage/route.tsmicrodollar_usagetable