From e41a153be24f3867ab375f9aea25f755270870f8 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Mon, 30 Dec 2024 22:54:52 +0000 Subject: [PATCH] fix: Make uid.Timestamp work on 32bit architectures (#11353) 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. --- internal/uid/uid.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/uid/uid.go b/internal/uid/uid.go index 2f229d647d44..d73e6fb7b2af 100644 --- a/internal/uid/uid.go +++ b/internal/uid/uid.go @@ -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