fix(types):现在日期和时间的指针形式解析不在对空白字符串报错了。

This commit is contained in:
徐涛 2023-06-26 13:29:34 +08:00
parent 062cc6a9ea
commit e6d9435c14
2 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ func ParseDate(t string) (Date, error) {
func ParseDatep(t string) (*Date, error) { func ParseDatep(t string) (*Date, error) {
if len(t) == 0 { if len(t) == 0 {
return nil, fmt.Errorf("不能解析空白的日期时间。") return nil, nil
} }
for _, layout := range dateLayouts { for _, layout := range dateLayouts {
d, err := time.ParseInLocation(layout, t, loc) d, err := time.ParseInLocation(layout, t, loc)

View File

@ -81,7 +81,7 @@ func ParseDateTime(t string) (DateTime, error) {
func ParseDateTimep(t string) (*DateTime, error) { func ParseDateTimep(t string) (*DateTime, error) {
if len(t) == 0 { if len(t) == 0 {
return nil, fmt.Errorf("不能解析空白的日期时间。") return nil, nil
} }
for _, layout := range datetimeLayouts { for _, layout := range datetimeLayouts {
fmt.Printf("Parse: %s, Try layout: %s\n", t, layout) fmt.Printf("Parse: %s, Try layout: %s\n", t, layout)