package com.smppw.common.rollrange.date.item;

import java.util.Calendar;

/**
 * @author Yu Liu
 *
 */
public class Week extends BaseDateTime {

	@Override
	public int between(Calendar startDate, Calendar endDate) {
		int numberOfDay = new Day().between(startDayOfPeriod(startDate), startDayOfPeriod(endDate));

		return numberOfDay / 7;
	}

	@Override
	public Calendar shift(Calendar startDate, int offside) {
		startDate.add(Calendar.WEEK_OF_YEAR, offside);
		return startDate;
	}

	@Override
	public Calendar startDayOfPeriod(Calendar date) {
		// Default SUNDAY is first day in a week.
		// If you want to set MONDAY as first day in a week. Please set as:
		date.setFirstDayOfWeek(Calendar.MONDAY);
		date.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
		return date;
	}

}
