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

Uploaded Source

Built Distribution

personnummer-3.2.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

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

Hashes for personnummer-3.2.1.tar.gz
Algorithm Hash digest
SHA256 5b319741d8b326ab4359427e1fa6b03101d48b19efc9d1a53cf17515fb4cc8b4
MD5 4cc9880cd346a9f09e7e347e99f85e87
BLAKE2b-256 eec5d9cbf6f8d368ed175240e757888f4c9ebe443b6cf36b11bee72d2bf4c51b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for personnummer-3.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15d6c42f87e84bb4a486a6076d29f4d823346e4b0545e3ff6af92e6e06bd05ed
MD5 7ca7220c1066d3e7f47d4b3be10c5f97
BLAKE2b-256 2258cf8e6dd8e25ee52c7db20f9a8da1f3e492ec28a7ae57c30533f83a6c2dff

See more details on using hashes here.

Supported by

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