Skip to content

DailyTotal uses UTC midnight instead of local timezone #4

Description

@rajfirke

Problem

SessionStore.DailyTotal() in internal/metrics/session.go:178 computes "today" as:

today := time.Now().Truncate(24 * time.Hour)

This truncates to UTC midnight, not local midnight. For users in non-UTC timezones, sessions started after local midnight but before UTC midnight are excluded from the daily total (or vice versa).

Example

User in UTC-8 (PST) at 5 PM local time (01:00 UTC next day). A session started at 9 AM local (17:00 UTC) has StartedAt.After(today) comparing against UTC midnight. The boundary is wrong by up to 12 hours.

Suggested Fix

now := time.Now()
today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())

Files

  • internal/metrics/session.go:174-186

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions