
function getBirthDateAndGender(idNumber) {
    if (idNumber && idNumber.length === 18) {
        const birthDate = idNumber.substring(6, 14);
        const gender = parseInt(idNumber.substring(16, 17), 10) % 2 === 0 ? '女' : '男';
        return { birthDate, gender };
    }
    return null;
}

function getAgeByIDCard(idCard) {
    if(!idCard)return 0
    const birthYear = idCard.substring(6, 10);
    const currentYear = new Date().getFullYear();
    const age = currentYear - parseInt(birthYear);
    return age;
}

export { getAgeByIDCard, getBirthDateAndGender }