Skip to content

Commit

Permalink
fix Age method
Browse files Browse the repository at this point in the history
  • Loading branch information
gouguoyin committed Oct 9, 2023
1 parent 9e289e2 commit 5d50dfb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion difference.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (c Carbon) DiffInYears(carbon ...Carbon) int64 {
}

dy, dm, dd := end.Year()-start.Year(), end.Month()-start.Month(), end.Day()-start.Day()
if dd < 0 || dm < 0 {
if dm < 0 || (dm == 0 && dd < 0) {
dy--
}
if dy < 0 && (dd != 0 || dm != 0) {
Expand Down

0 comments on commit 5d50dfb

Please sign in to comment.