Skip to content

TimeEpoch and TimeStamp use time.Local and contain magic numbers #522

@moonD4rk

Description

@moonD4rk

Problem

utils/typeutil/typeutil.go contains two time conversion functions with several issues:

TimeEpoch (Chrome WebKit epoch → time.Time)

  • Uses time.Local instead of time.UTC — Chrome stores times in UTC, so results vary depending on the machine's timezone
  • Uses a loop (for i := 0; i < 1000; i++) to work around int64 overflow instead of proper epoch conversion
  • maxTime = 99633311740000000 is an unexplained magic number
  • Overflow fallback returns 2049-01-01 01:01:01 with no explanation for this date
  • epoch = 0 returns 1601-01-01 instead of a zero value

TimeStamp (Unix timestamp → time.Time)

  • Uses s.Local().Year() mixing Local timezone into the check
  • Overflow fallback returns 9999-12-13 23:59:59 — the December 13th date appears arbitrary
  • stamp = 0 returns 1970-01-01 instead of a zero value

Impact

  • Time values displayed to users may be off by hours depending on timezone
  • Unit tests that assert on specific time values will fail in different CI timezones
  • Magic dates in fallback paths are confusing for maintainers

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions