-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Age method calculates the age incorrectly #181
Comments
The carbon2.2.0 version uses the Age method to calculate the age incorrectly. For example, the calculated age of a person whose birth date is 1938-09-02 on 2023-08-28 is calculated to be 85 years old, but the actual age should be 84 years old. The version before 2.2.0 calculated the age as The correct |
Fixed in version 2.2.6 |
判断条件应该由 现在的判断条件只判断天数差小于0就减一年而没有判断月份,导致大量的年龄计算错误。例:当前是2023-09-21,正常出生日期为2019-09-22至2020-09-21的人应该是3岁,现在这种判断条件会导致2020年1月到8月每个月21号之后出生的人会被计算成2岁。 @gouguoyin |
The judgment condition should be changed from The current judgment condition only judges that the difference in days is less than 0 and then subtracts one year without judging the month, resulting in a large number of age calculation errors. Example: The current date is 2023-09-21. A person with a normal birth date from 2019-09-22 to 2020-09-21 should be 3 years old. Now this judgment condition will result in 21 for each month from January to August 2020. People born after the number will be counted as 2 years old. @gouguoyin |
你在2023-09-26号应该测试2023年1月-8月中的27号及以后的日期,在2023-09-27号应该测试2023年1月-8月中的28号及以后的日期,同理2023-10-01号的时候1-9月除了1号那天正确,其他的日期都会小一岁 @gouguoyin |
You should test the 27th and later dates from January to August 2023 on 2023-09-26, and the 28th and later dates from January to August 2023 on 2023-09-27. , in the same way, when 2023-10-01 is the correct day from January to September, except the 1st, the other dates will be one year younger @gouguoyin |
Please give an example,assuming the current time is "2023-09-27" |
比如当前日期是2023-09-27,那么你计算2020-01-28至2020-01-31、2020-02-28至2020-02-31 ···· 一直到2020-08-28至2020-08-31这些日期都会比实际的小一岁。出现原因在于difference.go 第18行的条件判断有问题,应该把 |
For example, if the current date is 2023-09-27, then you calculate 2020-01-28 to 2020-01-31, 2020-02-28 to 2020-02-31... until 2020-08-28 to 2020- 08-31 These dates will be one year younger than the actual date. The reason is that there is a problem with the conditional judgment in line 18 of difference.go. You should change |
Fixed in v2.2.9 |
carbon2.2.0版本使用Age方法计算年龄错误,譬如2023-08-28计算出生日期为1938-09-02的人年龄计算出来的是85岁,实际应该是84岁,2.2.0之前的版本计算是正确的
The text was updated successfully, but these errors were encountered: