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

[BUG] - Age incorrect, does not account for month #103

Closed
flennic opened this issue Oct 4, 2024 · 2 comments
Closed

[BUG] - Age incorrect, does not account for month #103

flennic opened this issue Oct 4, 2024 · 2 comments
Labels

Comments

@flennic
Copy link
Contributor

flennic commented Oct 4, 2024

Context

It seems that the calculation of the age is wrong. Given that "today" is defined as 04.11.2024 and that the personal number is "19841120-0788":

Expected outcome

The age should be 39, as the person did not have birthday yet (20. November).

Actual outcome

Description

The calculation only takes into account the years (2024 - 1984) but does not account for the month. I am not sure this is maybe the "age" definition according to some law or personal number requirement. But if not, it is most likely a bug.

If you confirm that it is a bug, I can create a PR fixing the issue.

Minimal reproducible test case

Set system time to 04.10.2024, any time.

var personnummer = new Personnummer.Personnummer("19841120-0788");


Console.WriteLine(personnummer.Age);
@flennic flennic added the bug label Oct 4, 2024
@flennic
Copy link
Contributor Author

flennic commented Oct 4, 2024

PR created here: #104

@Johannestegner
Copy link
Member

Quite amazed that we haven't seen this before, quite a novice mistake on how I implemented the age check.
Thanks for the find! :)

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

No branches or pull requests

2 participants