提交 40d66ffe 编写于 作者: 张磊's avatar 张磊

name reg

上级 4bf97580
......@@ -91,17 +91,17 @@ export function toDecimal2(x) {
*/
export function getBirthdayAndSex(idCard) {
const info = {};
const birth = (idCard.length === 18) ? idCard.slice(6, 14) : idCard.slice(6, 12);
const birth =
idCard.length === 18 ? idCard.slice(6, 14) : idCard.slice(6, 12);
// 18位:提取第17位数字;15位:提取最后一位数字
const order = (idCard.length === 18) ? idCard.slice(-2, -1) : idCard.slice(-1);
info.birthDay = (idCard.length === 18) ? ([birth.slice(0, 4),
birth.slice(4, 6), birth.slice(-2)
]).join('-') : ([
'19' + birth.slice(0, 2), birth.slice(2, 4),
birth.slice(-2)
]).join('-');
const order = idCard.length === 18 ? idCard.slice(-2, -1) : idCard.slice(-1);
info.birthDay =
idCard.length === 18
? [birth.slice(0, 4), birth.slice(4, 6), birth.slice(-2)].join('-')
: ['19' + birth.slice(0, 2), birth.slice(2, 4), birth.slice(-2)].join(
'-'
);
// 余数为0代表女性,不为0代表男性
info.sex = (order % 2 === 0 ? 0 : 1);
info.sex = order % 2 === 0 ? 0 : 1;
return info;
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册