Skip to content

Commit

Permalink
Merge pull request #34 from open-git/patch-3
Browse files Browse the repository at this point in the history
Update final.go
  • Loading branch information
gouguoyin authored Jan 26, 2021
2 parents cf7dfb8 + 45c44f9 commit ee63908
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions final.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 输出日期时间字符串
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee63908

Please sign in to comment.