- Timestamp2Time Errorf when timestamp is in millisecond.
This commit is contained in:
@@ -72,7 +72,7 @@ const (
|
|||||||
const (
|
const (
|
||||||
CancelReasonClientActive = 101
|
CancelReasonClientActive = 101
|
||||||
CancelReasonClientChangeTimeOrAddress = 102
|
CancelReasonClientChangeTimeOrAddress = 102
|
||||||
CancelReasonGoodRelated = 103
|
CancelReasonGoodsRelated = 103
|
||||||
CancelReasonMerchantOther = 199
|
CancelReasonMerchantOther = 199
|
||||||
|
|
||||||
CancelReasonMtpsAttitude = 201
|
CancelReasonMtpsAttitude = 201
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package routinepool
|
|||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@@ -19,7 +18,7 @@ func init() {
|
|||||||
logger, _ := zap.NewDevelopment()
|
logger, _ := zap.NewDevelopment()
|
||||||
sugarLogger = logger.Sugar()
|
sugarLogger = logger.Sugar()
|
||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
rand.Seed(time.Now().Unix())
|
rand.Seed(utils.GetCurTimestamp())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCallFun(t *testing.T) {
|
func TestCallFun(t *testing.T) {
|
||||||
|
|||||||
@@ -135,10 +135,15 @@ func Int2Str(value int) string {
|
|||||||
|
|
||||||
// timestamp is in second
|
// timestamp is in second
|
||||||
func Timestamp2Str(timestamp int64) string {
|
func Timestamp2Str(timestamp int64) string {
|
||||||
return Time2Str(time.Unix(timestamp, 0))
|
return Time2Str(Timestamp2Time(timestamp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Timestamp2Time(timestamp int64) time.Time {
|
func Timestamp2Time(timestamp int64) time.Time {
|
||||||
|
const normalTimestamp = 1533709322
|
||||||
|
if timestamp > normalTimestamp*100 { // 传成毫秒了
|
||||||
|
baseapi.SugarLogger.Errorf("Timestamp2Time wrong timestamp:%d", timestamp)
|
||||||
|
timestamp = timestamp / 1000
|
||||||
|
}
|
||||||
return time.Unix(timestamp, 0)
|
return time.Unix(timestamp, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user