Coder Social home page Coder Social logo

rsa-id-number's Introduction

rsa-id-number

Utilities for working with South African ID numbers.

RSA ID Number Format

+-------------------------+
|8|8|0|1|2|3|5|1|1|1|0|8|8|
+-------------------------+
|Y|Y|M|M|D|D|S|S|S|S|C|A|Z|
+-------------------------+
  • YYMMDD: The first 6 digits represent the date of birth (23 January 1988)
  • SSSS: The next 4 digits are used to define the individual's gender (Male)
    • Female: 0000 - 4999
    • Male: 5000 - 9999
  • C: The next digit is used to classify citizenship (SA citizen)
    • SA citizen: 0
    • Permanent resident: 1
  • A: The next digit was used until 1980s to classify race
  • Z: The last digit is used as a checksum digit to verify the number (Valid)

Installation

$ pip install rsa-id-number

Usage

>>> import rsaidnumber
>>> id_number = rsaidnumber.parse('8801235111088')
>>> id_number.valid
True
>>> id_number.date_of_birth
datetime.datetime(1988, 1, 23, 0, 0)
>>> id_number.gender
<Gender.MALE: 2>
>>> id_number.citizenship
<Citizenship.SA_CITIZEN: 1>
>>> id_number = rsaidnumber.parse('8801235111080')
Traceback (most recent call last):
  ...
ValueError: '8801235111080' contains an invalid checksum digit!
>>> id_number = rsaidnumber.parse('8801235111080', False)
>>> id_number.valid
False

Contributing

Setup your development environment by running:

$ make

this will create a new Python virtualenv, install all necessary dependencies and run the tests.

rsa-id-number's People

Contributors

andreit avatar bevanmw avatar eduanmullertg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rsa-id-number's Issues

Incorrect date conversion for old id numbers

Screenshot 2020-08-06 at 16 40 22

There seems to be an issue that arises when you try and detect the date of birth of older individuals using datetime in python.
In this example it converts 59 03 19 to the year 2059 instead of 1959. This happens because datetime has to guess if it's supposed to use 1950 or 2000 as the base of reference.

The way I've resolved this before is to have it remove a 100 years if it ever gives a year in the future in this specific date of birth from id scenario.

ID Generation generated an invalid id

This came up during one of the circleci builds

Screenshot 2020-08-07 at 09 06 16

It looks like an id was generated and then found to be invalid, causing the build to fail on an unrelated branch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.