Skip to content
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

Wrong calculation #5

Open
Phoniexk opened this issue May 3, 2022 · 1 comment
Open

Wrong calculation #5

Phoniexk opened this issue May 3, 2022 · 1 comment

Comments

@Phoniexk
Copy link

Phoniexk commented May 3, 2022

Hi.

Your code is not calculating correctly.

Birthday = 02/23/2022 (MM/dd/yyyy)

Example Dates:
04/28/2022 => 0 Years, 2 Months, 5 Days
04/29/2022 => 0 Years, 2 Months, 6 Days
04/30/2022 => 0 Years, 2 Months, 7 Days
05/01/2022 => 0 Years, 2 Months, 6 Days (should be 8 Days)
05/02/2022 => 0 Years, 2 Months, 7 Days (should be 9 Days)
05/03/2022 => 0 Years, 2 Months, 8 Days (should be 10 Days)

The issue happens because you are calculating the days without considering the months / year. You have to calculate years & months at first and after this the remaining days.

@abreaux26
Copy link

I am getting another wrong calculation as well.

Bday: 08/15/2018 (MM/dd/yyyy)
Cday: 09/12/2022 (MM/dd/yyy)

I am getting -> 4 year(s), 0 month(s), and 28 day(s)
but is should be -> 4 year(s), 0 month(s), and 27 day(s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants