Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果要获取出生日期要添加什么代码呢 #12

Open
saber1024 opened this issue Sep 22, 2017 · 3 comments
Open

如果要获取出生日期要添加什么代码呢 #12

saber1024 opened this issue Sep 22, 2017 · 3 comments

Comments

@saber1024
Copy link

看了content那里貌似没有获取生日的代码

@yonlau
Copy link

yonlau commented Sep 29, 2017

也想知道

@Yueeeeee
Copy link

Yueeeeee commented Dec 7, 2017

https://jingyan.baidu.com/article/72ee561abd962fe16038df48.html
分析一下身份号就OK了

@JunsW
Copy link

JunsW commented Jan 24, 2018

提供一个Swift4.0的计算方法
先扩展两个便捷方法

extension {
  
    func substring(fromIndex: Int) -> String {
        return self[min(fromIndex, length) ..< length]
    }
    
    func substring(toIndex: Int) -> String {
        return self[0 ..< max(0, toIndex)]
    }
}

然后

        let birthday = idInfo.num.substring(fromIndex: 6).substring(toIndex: 14)
        let birthYear = birthday.substring(toIndex: 4)
        let birthMonth = birthday.substring(fromIndex: 5).sustring(toIndex: 6)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants