Merge pull request #8868 from AkihiroSuda/epoch-y2038

pkg/epoch: fix Y2038 on 32-bit hosts
This commit is contained in:
Fu Wei
2023-07-26 13:43:53 +08:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -73,7 +73,7 @@ func ParseSourceDateEpoch(sourceDateEpoch string) (*time.Time, error) {
// SetSourceDateEpoch sets the SOURCE_DATE_EPOCH env var.
func SetSourceDateEpoch(tm time.Time) {
_ = os.Setenv(SourceDateEpochEnv, strconv.Itoa(int(tm.Unix())))
_ = os.Setenv(SourceDateEpochEnv, fmt.Sprintf("%d", tm.Unix()))
}
// UnsetSourceDateEpoch unsets the SOURCE_DATE_EPOCH env var.

View File

@@ -17,9 +17,9 @@
package epoch
import (
"fmt"
"os"
"runtime"
"strconv"
"testing"
"time"
@@ -85,7 +85,7 @@ func TestSourceDateEpoch(t *testing.T) {
require.NoError(t, err)
require.True(t, vp.Equal(sourceDateEpoch.UTC()))
vp, err = ParseSourceDateEpoch(strconv.Itoa(int(sourceDateEpoch.Unix())))
vp, err = ParseSourceDateEpoch(fmt.Sprintf("%d", sourceDateEpoch.Unix()))
require.NoError(t, err)
require.True(t, vp.Equal(sourceDateEpoch))