Package sessn
validades, normalizes and generates Swedish SSNs,
or Personnummer. It has no external dependencies and supports regular,
coordination and interim numbers, and is written with clarity
and ease of use in mind.
Use sessn.Normalize
to check/normalize numbers before storing them, since it's
recommended
to store the 12-digit version, to avoid ambiguity.
The following formats (with whitespace trimmed) are recognized
(C
:century, Y
:year, M
:month, D
:day, I
:interim letter, B
:birth number, K
:check digit):
- Regular SSN:
- "CCYYMMDD-BBBK"
- "CCYYMMDD+BBBK"
- "CCYYMMDDBBBK"
- "YYMMDD-BBBK"
- "YYMMDD+BBBK"
- "YYMMDDBBBK"
- Interim number:
- "CCYYMMDD-IBBK"
- "CCYYMMDD+IBBK"
- "CCYYMMDDIBBK"
- "YYMMDD-IBBK"
- "YYMMDD+IBBK"
- "YYMMDDIBBK"
Test data from here.