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) 302 B
import { getBirthDate } from "./getBirthDate" export const getAge: (cnp: string) => number | undefined = cnp => { const birthDate = getBirthDate(cnp)! const difference = Date.now() - birthDate.getTime() const date = new Date(difference) return Math.abs(date.getUTCFullYear() - 1970) }