-
Notifications
You must be signed in to change notification settings - Fork 1.7k
TimeEpoch and TimeStamp use time.Local and contain magic numbers #522
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
utils/typeutil/typeutil.go contains two time conversion functions with several issues:
TimeEpoch (Chrome WebKit epoch → time.Time)
- Uses
time.Localinstead oftime.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 = 99633311740000000is an unexplained magic number- Overflow fallback returns
2049-01-01 01:01:01with no explanation for this date epoch = 0returns1601-01-01instead 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 = 0returns1970-01-01instead 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working