feat: 卡实名时间以上游 archiveTime 为准并记录实名时间历史,新增二次实名批次
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
This commit is contained in:
25
internal/gateway/upstream_time.go
Normal file
25
internal/gateway/upstream_time.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// upstreamLocation 是上游时间字段的时区(北京时间,固定 +08:00,不依赖系统时区数据库)。
|
||||
var upstreamLocation = time.FixedZone("CST", 8*3600)
|
||||
|
||||
var upstreamTimeLayouts = []string{"2006-01-02 15:04:05", "2006-01-02T15:04:05", "2006/01/02 15:04:05"}
|
||||
|
||||
// parseUpstreamTime 按北京时间解析上游时间字符串,空或无法解析返回 nil。
|
||||
func parseUpstreamTime(raw string) *time.Time {
|
||||
value := strings.TrimSpace(raw)
|
||||
if value == "" || strings.EqualFold(value, "null") {
|
||||
return nil
|
||||
}
|
||||
for _, layout := range upstreamTimeLayouts {
|
||||
if parsed, err := time.ParseInLocation(layout, value, upstreamLocation); err == nil {
|
||||
return &parsed
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user