From 5d50dfb53e4d12511d331807f1b9a3a50f077394 Mon Sep 17 00:00:00 2001 From: Peleus <245629560@qq.com> Date: Mon, 9 Oct 2023 09:49:03 +0800 Subject: [PATCH] fix Age method --- difference.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/difference.go b/difference.go index 9de442a7..f0dca578 100755 --- a/difference.go +++ b/difference.go @@ -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) {