Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/personnummer/python
Validate Swedish personal identity numbers
https://github.com/personnummer/python
hacktoberfest personal-identity-number personnummer python social-security-number validation
Last synced: 10 days ago
JSON representation
Validate Swedish personal identity numbers
- Host: GitHub
- URL: https://github.com/personnummer/python
- Owner: personnummer
- License: mit
- Created: 2017-10-21T20:11:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T18:38:43.000Z (about 2 months ago)
- Last Synced: 2024-11-14T08:35:20.926Z (29 days ago)
- Topics: hacktoberfest, personal-identity-number, personnummer, python, social-security-number, validation
- Language: Python
- Homepage: https://pypi.org/project/personnummer/
- Size: 121 KB
- Stars: 12
- Watchers: 5
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sweden - Python
README
# personnummer [![Build Status](https://github.com/personnummer/python/workflows/test/badge.svg)](https://github.com/personnummer/python/actions)
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 with `personnummer.parse([params])`.
### Validation
```python
from personnummer import personnummerpersonnummer.valid("8507099805")
# => Truepersonnummer.valid("198507099805")
# => True
```### Format
```python
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_```python
from personnummer import personnummerpn = personnummer.Personnummer('19121212+1212')
pn.get_date()
# => datetime.date(1912, 12, 12)
```### Get Age
```python
from personnummer import personnummerpn = personnummer.Personnummer("19121212+1212")
pn.get_age()
# => 106
```See [personnummer/tests/test_personnummer.py](personnummer/tests/test_personnummer.py) for more examples.
## License
MIT