Skip to content
/ jmbg Public

A go library to parse the Serbian JMBG (Jedinstveni Matični Broj Građana), or UMCN (Unique Master Citizen Number)

License

Notifications You must be signed in to change notification settings

dusnm/jmbg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JMBG

License: LGPL v3 semver Tests Go Report Card

A go library to parse the Serbian JMBG (Jedinstveni Matični Broj Građana), or UMCN (Unique Master Citizen Number)

Explanation

The number that the government of Serbia assigns to its citizens is not random and is made up of the following information:

  • A person's date of birth
  • Which region of the country they were born in
  • The sex they were assigned at birth
  • A single digit checksum for error detection
type (
	JMBG struct {
		Number      string
		Digits      [13]uint
		DateOfBirth time.Time
		Region      region.Region
		Sex         sex.Sex
		Checksum    checksum.Checksum
	}
)

This library attempts to make it simple to extract this information out of a string representation of this number.

Installation

Make sure you have Go installed (download here).

Initialize your project in a directory of your choice and run go mod init github.com/your-username/your-repo-name. Then install the package with the go get command:

go get -u github.com/dusnm/[email protected]

Basic usage

package main

import (
	"fmt"
	"log"

	"github.com/dusnm/jmbg"
)

func main() {
	number := "0101000805018"

	data, err := jmbg.New(number)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(data)
}

Licensing

Licensed under the terms of the GNU Lesser General Public License, version 3

About

A go library to parse the Serbian JMBG (Jedinstveni Matični Broj Građana), or UMCN (Unique Master Citizen Number)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages