Validate Swedish personal identity numbers
Project description
personnummer
Validate Swedish personal identity numbers. Version 3+ only supports Python 3.
Installation
pip install personnummer
or
pip3 install personnummer
Examples
- All examples that uses
personnummer.Personnumer([params])
, can be replaced withpersonnummer.parse([params])
.
Validation
from personnummer import personnummer
personnummer.valid("8507099805")
# => True
personnummer.valid("198507099805")
# => True
Format
from personnummer import personnummer
# Short format
pn = personnummer.Personnummer(8507099805)
pn.format()
# => '850709-9805'
# Long format
pn = personnummer.Personnummer('8507099805')
pn.format(True)
# => '198507099805'
Get Date
New in version 3.2.0
from personnummer import personnummer
pn = personnummer.Personnummer('19121212+1212')
pn.get_date()
# => datetime.date(1912, 12, 12)
Get Age
from personnummer import personnummer
pn = personnummer.Personnummer("19121212+1212")
pn.get_age()
# => 106
See personnummer/tests/test_personnummer.py for more examples.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
personnummer-3.2.1.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file personnummer-3.2.1.tar.gz
.
File metadata
- Download URL: personnummer-3.2.1.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b319741d8b326ab4359427e1fa6b03101d48b19efc9d1a53cf17515fb4cc8b4 |
|
MD5 | 4cc9880cd346a9f09e7e347e99f85e87 |
|
BLAKE2b-256 | eec5d9cbf6f8d368ed175240e757888f4c9ebe443b6cf36b11bee72d2bf4c51b |
File details
Details for the file personnummer-3.2.1-py3-none-any.whl
.
File metadata
- Download URL: personnummer-3.2.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15d6c42f87e84bb4a486a6076d29f4d823346e4b0545e3ff6af92e6e06bd05ed |
|
MD5 | 7ca7220c1066d3e7f47d4b3be10c5f97 |
|
BLAKE2b-256 | 2258cf8e6dd8e25ee52c7db20f9a8da1f3e492ec28a7ae57c30533f83a6c2dff |