Files
junhong_cmp_fiber/internal/gateway/upstream_time.go
邹进 4967f4df43
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
feat: 卡实名时间以上游 archiveTime 为准并记录实名时间历史,新增二次实名批次
2026-11-08 19:12:46 +09:00

26 lines
750 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}