Skip to content

Commit

Permalink
update version from 2.0.0 to 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Nov 17, 2021
1 parent 9e48cce commit 5d3e476
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion carbon.go
@@ -1,7 +1,7 @@
// @Package carbon
// @Description a simple, semantic and developer-friendly golang package for datetime
// @Page github.com/golang-module/carbon
// @Version v2.0.0
// @Version v2.0.1
// @Author gouguoyin
// @Blog www.gouguoyin.cn
// @Email contact@gouguoyin.cn
Expand Down
11 changes: 6 additions & 5 deletions parser.go
Expand Up @@ -33,11 +33,12 @@ func (c Carbon) Parse(value string, timezone ...string) Carbon {
layout = ShortDateTimeFormat
}
}
if c.ParseByLayout(value, layout).Error != nil {
c = c.ParseByLayout(value, layout)
if c.Error != nil {
c.Error = invalidValueError(value)
return c
}
return c.ParseByLayout(value, layout)
return c
}

// Parse parses a standard string as a Carbon instance.
Expand All @@ -58,12 +59,12 @@ func (c Carbon) ParseByFormat(value string, format string, timezone ...string) C
if value == "" || value == "0" || value == "0000-00-00 00:00:00" || value == "0000-00-00" || value == "00:00:00" {
return c
}
layout := format2layout(format)
if c.ParseByLayout(value, layout).Error != nil {
c = c.ParseByLayout(value, format2layout(format))
if c.Error != nil {
c.Error = invalidFormatError(value, format)
return c
}
return c.ParseByLayout(value, layout)
return c
}

// ParseByFormat parses a string as a Carbon instance by format.
Expand Down

0 comments on commit 5d3e476

Please sign in to comment.