UNPKG

cnp-decoder

Version:

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

7 lines (6 loc) 268 B
import { getBirthYear } from "./getBirthYear" export const getBirthDay: (cnp: string) => number | undefined = cnp => { const year = getBirthYear(cnp)! const date = new Date(year, parseInt(cnp.slice(3, 5)), parseInt(cnp.slice(5, 7))) return date.getDay() }