Skip to content

Commit

Permalink
fix: Make uid.Timestamp work on 32bit architectures (#11353)
Browse files Browse the repository at this point in the history
strconv.Atoi fails because the nanoseconds part of the string does not fit in an int, instead use ParseInt to get an int64.

As time.Date only takes an int for the nanoseconds part, use Add() separately instead as it takes a Duration, which is an int64.
  • Loading branch information
pterjan authored Dec 30, 2024
1 parent 8ebcc6d commit e41a153
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/uid/uid.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ func (s *Space) Timestamp(uid string) (time.Time, bool) {
y, err1 := strconv.Atoi(subs[1])
m, err2 := strconv.Atoi(subs[2])
d, err3 := strconv.Atoi(subs[3])
ns, err4 := strconv.Atoi(subs[4])
ns, err4 := strconv.ParseInt(subs[4], 10, 64)
if err1 != nil || err2 != nil || err3 != nil || err4 != nil {
return time.Time{}, false
}
return time.Date(y, time.Month(m), d, 0, 0, 0, ns, time.UTC), true
return time.Date(y, time.Month(m), d, 0, 0, 0, 0, time.UTC).Add(time.Duration(ns)), true
}

// Older reports whether uid was created by m and has a timestamp older than
Expand Down

0 comments on commit e41a153

Please sign in to comment.