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

Refactored Age Calculation Logic with Improved Date Handling #1425

Merged

Conversation

KashishJuneja101003
Copy link
Contributor

Project-Guidance! ๐ŸŽŠ๐ŸŽˆ

Welcome! ๐ŸŽ‰

Thank you for visiting our repository! We're excited to have you here. If you find this project useful, please consider giving it a star! โญ

๐ŸŽ‰ Have you reviewed the Contributing Guidelines? ๐Ÿค” (Required)

  • YES
  • NO

๐Ÿ“ Description

I refactored the existing code in age.py to improve the accuracy and readability of the age calculation logic. Specifically, I addressed the following points:

  1. Improved Date Handling: The code now accurately handles cases where the day or month of the birthday has not yet occurred in the current year. This is done by adjusting the year and month calculations accordingly.
  2. Day Calculation Fix: If the days between the birthday and the current date are negative (meaning the current day is earlier than the birthday day), the month is decremented, and the correct number of days in the previous month is used to adjust the day count. This ensures that the output always shows non-negative values for days.
  3. Month Calculation Adjustment: If the months between the current date and birthday are negative (i.e., the birthday month is later in the year than the current month), the year is decremented by 1, and the months are adjusted to ensure that the final age is displayed accurately.
  4. Error Handling: Improved the error handling mechanism to catch invalid date formats and provide user-friendly messages.

๐Ÿ”ง Fixes #issue_no (Required)

Issue number #1358

๐Ÿท๏ธ Initiative Participation (Required)

This pull request is associated with the following initiative. Please choose the one you are contributing to:

  • ๐ŸŒธ GSSoC (Girl Script Summer of Code)
  • ๐ŸŒผ GSSoC 2024 Extd.
  • ๐Ÿ‚ Hacktoberfest 2024
  • โ„๏ธ Script Winter of Code (SWoC)
  • โ›„ Winter of Blockchain (WoB)
  • ๐Ÿ™‹โ€โ™‚๏ธ Personal
  • ๐Ÿ“Œ Other (please specify): _______________

It is a complete different code than age.py
Copy link

@KashishJuneja101003

It's great having you contribute to this project

Thank you for opening a Pull Request ๐Ÿ™Œ , Welcome to Project Guidance ๐Ÿ’– We will review everything and get back to you :)

@KashishJuneja101003
Copy link
Contributor Author

KashishJuneja101003 commented Oct 11, 2024

I changed to entire code, thus I uploaded a different file for the updates code namely "Updated age.py".

Iโ€™m new to GSSoC and GitHub, so please forgive me if I made any mistakes during this process. I appreciate any feedback you may have, and let me know if any changes are required.

Kindly assign the level too.

Thank You!

@Kushal997-das
Copy link
Owner

I changed to entire code, thus I uploaded a different file for the updates code namely "Updated age.py".

Iโ€™m new to GSSoC and GitHub, so please forgive me if I made any mistakes during this process. I appreciate any feedback you may have, and let me know if any changes are required.

Kindly assign the level too.

Thank You!

@KashishJuneja101003 No worries, feel free to ask your question , please update the existing file instead of creating a new one.

@Kushal997-das Kushal997-das added Hold Iโ€™m waiting for additional responses before proceeding. hacktoberfest2024 Your contribution is part of Hacktoberfest 2024! ๐ŸŽ‰ gssoc-ext This level is for GSSOC-Extended. labels Oct 13, 2024
@KashishJuneja101003
Copy link
Contributor Author

@Kushal997-das
I tried to clone the repository but I couldn't. The repository is very big in size maybe that's why.
Thus, I had to upload a different file.
Kindly, let me know if there is any other way to do the same.
Thank you!

@Kushal997-das
Copy link
Owner

Hi @KashishJuneja101003 ,

I noticed that you've already cloned the project. Could you please update the existing .py file with the necessary changes instead of creating a new file?

Thank you!

@KashishJuneja101003
Copy link
Contributor Author

Kindly review my pull request.
Thank You!

Copy link
Owner

@Kushal997-das Kushal997-das left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @KashishJuneja101003 ,
I wanted to address a logical inconsistency regarding the dates provided. A date of birth (DOB) of 10/10/2003 (October 10, 2003) cannot occur before today's date of 03/10/2003 (March 10, 2003) within the same year.

To clarify:

  • DOB: 10/10/2003 indicates the person was born on October 10, 2003.
  • Today's Date: 03/10/2003 signifies it is March 10, 2003.

Since the DOB falls later in the year than todayโ€™s date, it is not possible for someone to be born on October 10, 2003, before March 10, 2003.

Given this clarification, I will be closing this PR and issue.

Thank you for your understanding.

@Kushal997-das Kushal997-das added invalid You either opened a PR without an issue or the files aren't appropriate. and removed Hold Iโ€™m waiting for additional responses before proceeding. labels Oct 14, 2024
@Kushal997-das Kushal997-das reopened this Oct 16, 2024
@Kushal997-das Kushal997-das removed the invalid You either opened a PR without an issue or the files aren't appropriate. label Oct 16, 2024
@Kushal997-das
Copy link
Owner

Hi @KashishJuneja101003,

I noticed there's some conflict arising. Can you please take a moment to discuss and resolve it?

Thanks!

@Kushal997-das Kushal997-das added the Changes-required Little bit changes required . label Oct 16, 2024
@KashishJuneja101003
Copy link
Contributor Author

I resolved this issue.
Kindly check if PR gets merged now.
Thank You!

@Kushal997-das Kushal997-das added Status Update: Approved! โœ… Awesome! ๐ŸŽ‰ This PR has been approved! Let the celebration begin! ๐Ÿš€ and removed Changes-required Little bit changes required . labels Oct 17, 2024
@Kushal997-das Kushal997-das added hacktoberfest-accepted โ€œhacktoberfest-acceptedโ€ label level1 Under level 1 labels Oct 17, 2024
@Kushal997-das Kushal997-das merged commit 86171ba into Kushal997-das:main Oct 17, 2024
1 check passed
Copy link

@KashishJuneja101003 Hurray, your PR got merged into our Project-Guidance ๐Ÿฅณ. Thanks a bunch. Feel free to take another Issue. ๐Ÿ’–

@KashishJuneja101003 KashishJuneja101003 deleted the issueResolvedBranch branch October 17, 2024 07:01
@KashishJuneja101003
Copy link
Contributor Author

Hello,
My issue #1358 is still active. Could you please close this issue under pull request #1425
Thank You!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gssoc-ext This level is for GSSOC-Extended. hacktoberfest2024 Your contribution is part of Hacktoberfest 2024! ๐ŸŽ‰ hacktoberfest-accepted โ€œhacktoberfest-acceptedโ€ label level1 Under level 1 Status Update: Approved! โœ… Awesome! ๐ŸŽ‰ This PR has been approved! Let the celebration begin! ๐Ÿš€
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants