Corrected the reference day calculation