Skip to content

Instantly share code, notes, and snippets.

View wilsoncampusano's full-sized avatar
🎯
Focused

Wilson Campusano Jorge wilsoncampusano

🎯
Focused
View GitHub Profile
@andatta
andatta / CalculateAge.swift
Created May 23, 2017 05:46
Swift code to calculate age in years, months and days from a person's dob
func calculateAge(dob : String) -> (year :Int, month : Int, day : Int){
let df = NSDateFormatter()
df.dateFormat = "yyyy-MM-dd"
let date = df.dateFromString(dob)
guard let val = date else{
return (0, 0, 0)
}
var years = 0
var months = 0
var days = 0