From 5d3e476068e1733e3cb8189b512bc174978ca47a Mon Sep 17 00:00:00 2001 From: gouguoyin <245629560@qq.com> Date: Wed, 17 Nov 2021 12:20:40 +0800 Subject: [PATCH] update version from 2.0.0 to 2.0.1 --- carbon.go | 2 +- parser.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/carbon.go b/carbon.go index f7b21567..e4242eac 100755 --- a/carbon.go +++ b/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 diff --git a/parser.go b/parser.go index 4909d6f8..4163ad7b 100755 --- a/parser.go +++ b/parser.go @@ -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. @@ -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.