From 45c44f9afb3daa0a540c1ffebfc83e633bd781b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90GIT?= <33504916+open-git@users.noreply.github.com> Date: Tue, 26 Jan 2021 23:36:44 +0800 Subject: [PATCH] Update final.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ToDayDateTimeString()方法缺少In(c.Loc) --- final.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/final.go b/final.go index ef4fb9c3..dbcb0acb 100755 --- a/final.go +++ b/final.go @@ -57,7 +57,7 @@ func (c Carbon) ToDayDateTimeString() string { if c.Time.IsZero() { return "" } - return c.Time.Format(DayDateTimeFormat) + return c.Time.In(c.Loc).Format(DayDateTimeFormat) } // ToDateTimeString 输出日期时间字符串 @@ -386,8 +386,8 @@ func (c Carbon) Age() int { if c.ToTimestamp() > Now().ToTimestamp() { return 0 } - age := time.Now().Year() - c.Time.Year() - if int(time.Now().Month())*100+time.Now().Day() < int(c.Time.Month())*100+c.Time.Day() { + age := time.Now().Year() - c.Time.In(c.Loc).Year() + if int(time.Now().Month())*100+time.Now().Day() < int(c.Time.In(c.Loc).Month())*100+c.Time.In(c.Loc).Day() { age = age - 1 } return age