mirror of
https://gitee.com/dromara/carbon.git
synced 2024-11-29 18:57:37 +08:00
修复年龄计算错误的 bug
This commit is contained in:
parent
b88ad25bd8
commit
4f7b402a16
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user