fixed periods_between() so it returns correctly if end_date is equal to end of a period