Merge pull request #8868 from AkihiroSuda/epoch-y2038
pkg/epoch: fix Y2038 on 32-bit hosts
This commit is contained in:
commit
bdbcf96267
@ -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.
|
||||
|
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user