Have a go at the CGT exemption tool from the ATO website. It looks like it's based on the loan interst percentage i.e. the portion of granny flat loan from your total loan..
I plugged in some values and the percentage of capital gain to be offset didn't take into account the portion of time...