A nonconforming building damaged by fire, explosion, act of God or any other casualty to an extent less than 50 percent of replacement cost at the time such damage occurred as determined by the building official may be restored and the building or portion of such building that existed at the time of such damage may be repaired provided all repairs have been made and a certificate of occupancy has been issued within 12 months of such damage, subject to all other provisions of this chapter and applicable city codes. The building official may grant an extension of up to six additional months upon issuing a written finding that the owner has diligently pursued restoration of the building.