jmbg

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2023 License: LGPL-3.0 Imports: 6 Imported by: 0

README

JMBG

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/jmbg@v1.0.0

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JMBG

type JMBG struct {
	Number      string            `json:"number"`
	Digits      [13]uint          `json:"digits"`
	DateOfBirth time.Time         `json:"date_of_birth"`
	Region      region.Region     `json:"region"`
	Sex         sex.Sex           `json:"sex"`
	Checksum    checksum.Checksum `json:"checksum"`
}

func New

func New(jmbg string) (JMBG, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL