Skip to main content

Validate Swedish personal identity numbers

Project description

personnummer Build Status

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

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


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.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

personnummer-3.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file personnummer-3.2.0.tar.gz.

File metadata

  • Download URL: personnummer-3.2.0.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

Hashes for personnummer-3.2.0.tar.gz
Algorithm Hash digest
SHA256 cac87003ba6ba1cf34c9ef56a7d11fa1a475380e3f5cd5594a0d3899c2da17de
MD5 c5a00a064421bc07dd9ee77df41e6f3c
BLAKE2b-256 67f2ca49aafa7c92ae12bcd409e47603534f435c844572c551c2aedee2fd1c46

See more details on using hashes here.

File details

Details for the file personnummer-3.2.0-py3-none-any.whl.

File metadata

  • Download URL: personnummer-3.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for personnummer-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5297d5cc41309bed8775f53497af8b935db1e70102f4286d108e6c24ff5a1fd6
MD5 2d28738425f2a2dd02efad5f2b5a4fc0
BLAKE2b-256 bd3a7c3edc9b2f9ca7c6ef56e4a2e02f1280dc04eb5d5d2fc270fa03bd0ff22c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page