居民身份证有18位公民身份号码,外国人永久居留身份证有15位号码。 居民身份证的身份号码有8位出生日期码,所以我们实名认证的时候不要手动输入生日。外国人永久身份证也有出生日期码,但这是6位。
function takeDate(id: string) {
if (id.length === 18) {
return Some(id.substring(6, 14));
} else if (id.length === 15) {
return Some(id.substring(7, 13));
}
return None();
}
// the ID used at https://baike.sogou.com/v101682730.htm
takeDate('110102197810272321'); // => Some('19781027')
// the ID used at https://baike.sogou.com/v164541405.htm
takeDate('CAN110081080319'); // => Some('810803')