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

French special month codes #61

Closed
SLourenco opened this issue Jun 11, 2020 · 1 comment · Fixed by #62
Closed

French special month codes #61

SLourenco opened this issue Jun 11, 2020 · 1 comment · Fixed by #62
Assignees
Labels
bug Something isn't working
Milestone

Comments

@SLourenco
Copy link

Following this reference documentation (cited in wikipedia) there is the possibility of special digits for the month section of the french national identity card number:

6.3 3 ème composante : mois de naissance (2 chiffres)
codification : de 01 (janvier) à 12 (décembre)
Les mois de naissance fictifs 20 à 30 ou 50 ou plus caractérisent le NIR d'une personne inscrite aurépertoire sur la base d'une pièce d'état civil ne mentionnant pas son mois de naissance (cf.précisions complémentaires).Les mois de naissance "pseudo-fictifs" 31 (janvier) à 42 (décembre) caractérisent le NIR d'unepersonne inscrite au répertoire sur la base d'une pièce d'état civil incomplète mais mentionnanttoutefois un mis de naissance.
from Normalisation du numéro INSEEdes personnes physiques

Which means (if google translate does not fail me) that the following options are available:

  • 01 - 12: Representing the month of the year
  • 20 - 30, 50: Indicating that the month of birth is unknown
  • 31 - 42: The person has an incomplete civil status document, but their month of birth is known

It seems to me that the current code will fail with any of the special digits:

private function getDateOfBirth(string $id): Carbon
{
  $dateDigits = substr($id, 1, 4);
  [$year, $month] = str_split($dateDigits, 2);
  $currentYear = (int) now()->format('y');

  $year = (int) $year > $currentYear ? (int) $year + 1900 : (int) $year + 2000;

  return Carbon::createFromFormat('Y-m', "$year-$month");
}

The extraction should have the month of birth information, even with the 31-42 digits, and ideally not fail (rather be incomplete) on the 20-30 or 50 digits.

@AlexOlival AlexOlival added the bug Something isn't working label Jun 11, 2020
@AlexOlival AlexOlival added this to the v1.1.1 Update milestone Jun 11, 2020
@JoaoFSCruz
Copy link
Collaborator

I had checked there were some nuances on the month but never really got into it and totally forgot about them. I'll get down to it as soon as possible. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants