fixed incorrect start day of week calculation and leap year bug