feat: sale add create user

This commit is contained in:
zzw
2026-09-02 09:47:34 +08:00
parent ad4bc7de85
commit 540f74f9b7
39 changed files with 2023 additions and 282 deletions
+20
View File
@@ -217,3 +217,23 @@ func ParseCustomTime(s string) (CustomTime, error) {
}
return ct, nil
}
// ParseDateOnly 解析 YYYY-MM-DD;空串返回零值(写入 DB 为 NULL)
func ParseDateOnly(s string) (CustomTime, error) {
if s == "" {
return CustomTime{}, nil
}
t, err := time.ParseInLocation(time.DateOnly, s, AsiaShanghai)
if err != nil {
return CustomTime{}, fmt.Errorf("invalid date format: %s", s)
}
return CustomTime{Time: t}, nil
}
// DateString 返回 YYYY-MM-DD;零值返回空串
func (ct CustomTime) DateString() string {
if ct.IsZero() {
return ""
}
return ct.Time.Format(time.DateOnly)
}