export function getAge(IDCord:string){
    var yearBirth = IDCord.substring(6,10);
    var monthBirth = IDCord.substring(10,12);
    var dayBirth = IDCord.substring(12,14);
    // 获取当前年月日并计算年龄
    var myDate = new Date();
    var monthNow = myDate.getMonth() + 1;
    var dayNow = myDate.getDate();
    var age = myDate.getFullYear() - yearBirth;
    if(monthNow < monthBirth || (monthNow == monthBirth && dayNow < dayBirth)){
      age --;
    }
    return age
  }

export function getBirth(IDCord:string) {
    var yearBirth = IDCord.substring(6,10);
    var monthBirth = IDCord.substring(10,12);
    var dayBirth = IDCord.substring(12,14);
    return `${yearBirth}-${monthBirth}-${dayBirth}`
}
export function arrayGroupBy(list, groupId){
    function groupBy(array, f){
        const groups = {}
        array.forEach(function (o) {
            const group = JSON.stringify(f(o))
            groups[group] = groups[group] || []
            groups[group].push(o)
        })

        return groups;
    };
    return groupBy(list, function (item) {
        return item[groupId]
    });
}

