Added prev_weekday function