A lots of info we can get from Malaysian IC. So, I got a task to make a function to extract date of birth from user's IC.Took me less then 10 lines of code.
from datetime import datetime
from dateutil.relativedelta import relativedelta
dob = ic[0:6] # strip unnecessary info from ic
dob = datetime.strptime(dob,'%y%m%d')# convert it to date format
today = datetime.now()
age = relativedelta(today, dob) # date different between ic date and today
data = "%d years %d month and %d days" %(age.years, age.months, age.days)
That was like what, 9 lines of code?