API specification¶
-
class
estnin.estnin(estnin, set_checksum=False)[source]¶ Provides an representation for Estonian national identity number.
Create a new instance from given value.
Parameters: - estnin (
str()orint()) – value to create an EstNIN representation for. - set_checksum (
bool) – if set toTruethen recalculate and set the checksum value.
Returns: estninobjectReturn type: Raises: ValueErrorif invalid value is given.- Usage:
>>> from estnin import estnin >>> estnin(37001011233) 37001011233 >>> estnin("37001011230", set_checksum=True) 37001011233
-
MIN= 10001010002¶ First valid value (minimum as a number).
-
MAX= 89912319991¶ Last valid value (maximum as a number).
-
MALE= 0¶ Value used by
estnin.createmethod to indicate that the new EstNIN should be created for a male.
-
FEMALE= 1¶ Value used by
estnin.createmethod to indicate that the new EstNIN should be created is for a female.
-
classmethod
create(sex, birth_date, sequence)[source]¶ Create a new instance by providing the sex, birth date and sequence.
Parameters: - sex (
estnin.MALEorestnin.FEMALE) – use falsy for male and truthy value for female - birth_date (
datetime.date()) – date of birth - sequence (
int()) – value in[0 - 999]specifing the sequence number on given day
Returns: estnin.estninobjectReturn type: Raises: ValueErrorif invalid value is provided- Usage:
>>> from estnin import estnin >>> from datetime import date >>> estnin.create(estnin.MALE, date(1970, 1, 1), 123) 37001011233
- sex (
-
is_male¶ Returns
Trueif the EstNIN represents a male.Return type: bool
-
is_female¶ Returns
Trueif the EstNIN represents a female.Return type: bool
-
century¶ Century property that returns the century digit in the EstNIN or sets it accordingly.
Getter: return the century digit as int().Setter: update the century digit given as int()orstr().Modifies: checksum Raises: ValueErrorif century value is not in range[1..8]- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.century 3 >>> person.century = 5 >>> person 57001011235
-
year¶ Year property that returns the year in the EstNIN or sets it accordingly.
Getter: return the year as int()in the format ofYYYY.Setter: update the year given as int()orstr()in the format ofYYYY.Modifies: century, checksum Raises: ValueErrorif year value is not in range[1800..2199]- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.year 1970 >>> person.year = 2001 >>> person 50101011235
-
month¶ Month property that returns the month in the EstNIN or sets it accordingly.
Getter: return the month as int()in the format ofMM.Setter: update the month given as int()orstr()in the format ofMM.Modifies: checksum Raises: ValueErrorif month value is not in range[1..12]- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.month 1 >>> person.month = 12 >>> person 30112011231
-
day¶ Day property that returns the day in the EstNIN or sets it accordingly.
Getter: return the day as int()in the format ofDD.Setter: update the day given as int()orstr()in the format ofDD.Modifies: checksum Raises: ValueErrorif day value is not valid for given month.- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.day 1 >>> person.day = 31 >>> person 37001311233
-
sequence¶ Sequence property that returns the sequence in the EstNIN or sets it accordingly.
Getter: return the sequence as int().Setter: update the sequence given as int()orstr().Modifies: checksum Raises: ValueErrorif sequence value is not in range[0..999].- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.sequence 123 >>> person.sequence = 42 >>> person 37001010421
-
checksum¶ Checksum property that returns the checksum digit in the EstNIN.
Getter: return the checksum as int().- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.checksum 3
-
date¶ Date property that returns the date representated in the EstNIN.
Getter: return the date as datetime.date().Setter: update the date given as datetime.date().Modifies: century, checksum Raises: ValueErrorif invalid date is given.- Usage:
>>> from estnin import estnin >>> person = estnin(37001011233) >>> person.date datetime.date(1970, 1, 1) >>> person.date = person.date.replace(year=1972, day=22) >>> person.date datetime.date(1972, 1, 22) >>> person 37201221236
- estnin (