Refactor nth_of_day to be reusable