rodnecislo

A package for handling Czech and Slovak personal ID

View the Project on GitHub kub1x/rodnecislo

rodnecislo

NPM Version NPM downloads License Github Issues Travis Status Coveralls Greenkeeper badge

A npm package for validating and deriving information from Czech and Slovak National Identification Number. This number is used in Czech and Slovak Republic as the primary unique identifier for every person by most, if not all, government institutions, banks, etc. It consists of two parts: birth date (with gender mark) and serial number with check digit. It is commonly known as Birth Number or rodné číslo in both Czech and Slovak hence the library name.

Install

Works with nodejs v10 and higer (ES2015).

npm install rodnecislo

Usage

import { rodnecislo } from 'rodnecislo';
// let { rodnecislo } = require("rodnecislo")

let rc = rodnecislo('111213/3121')

rc.isMale()     // true
rc.isFemale()   // false

rc.year()       // 2011
rc.month()      // 11 - zero based month
rc.day()        // 13

rc.birthDate()  // new Date(2011, 11, 13) - "Tue Dec 13 2011 00:00:00 GMT+0100 (CET)"
rc.birthDateAsString() // "13.12.2011" - the Czech date format

rc.isValid()    // true
rc.isPossible() // true (valid, but maybe in the future)

rc.isAdult()    // false - by default checks if current date is above 18 years old
rc.isAdult(21)  // false - for US

rc.age()        // 5 - age today (it is 5.6.2017 ;)

rc.dic()        // "CZ1112133121" - Czech Tax Identification Number (DIč)

Definitions and legislation

Dictionary

Historical evolution

Before 1953

After 1953

After 1985

In 1993 Czechoslovakia split into Czech Republic and Slovak Republic

After 2004

So to wrap it up

Short/long version

Month/Gender

Modulo condition

Age and Adultood

According to Civil code §601 law n. 89/2012 and §30 of New Civil Code an age is reached at midnight which is starting the birthday. So on the first seconds of your 18th birthday you can start drinking in Czech.

VAT Identification Number

In Czech the personal VAT Identification Number is derived from Birth Number by adding CZ prefix and ommitting the slash. It is called Daňové identifikační číslo (DIČ) hence the .dic() method.

Sources

Specification comes mainly from following links:

RegExp

RegExp for rodné číslo. With/without slash.

  |   1   |      2a      |       2b      |       2c      |       2d       |             3          |4 |    5   |
/^\d{0,2}((0[1-9]|1[0-2])|(2[1-9]|3[0-2])|(5[1-9]|6[0-2])|(7[1-9]|8[0-2]))(0[1-9]|[1-2][0-9]|3[01])\/?[0-9]{3,4}$/;

Explanation:

Unanswered Questions

Author

Jakub Podlaha j.podlaha@gmail.com

License

MIT : http://opensource.org/licenses/MIT

Contributing

Don’t hesitate to let me know about errors and/or possible uselessnesses. I did this for my project first but would be glad if others find this useful.