UNPKG

cnp-decoder

Version:

A function that decodes a romanian CNP and returns a object containing informations about the person it belongs to

9 lines (7 loc) 287 B
import { getBirthDay, getBirthMonth, getBirthYear } from "./utils" export const getBirthDate: (cnp: string) => Date | undefined = cnp => { const year = getBirthYear(cnp)! const month = getBirthMonth(cnp)! const day = getBirthDay(cnp) return new Date(year, month, day) }