package org.treesched.schedules;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.treesched.RegularSchedule;

/**
 * Schedule for weekly events. This schedule will schedule it's sub schedules weekly.
 * It will look forwared look-forward-weeks (default 52) weeks before returning NEVER.
 * <p>
 * Typical configuration:
 * <code><pre>
 * &lt;weekly/&gt;
 * </pre></code>
 * 
 * @author Rob Gordon
 */

public final class WeeklySchedule extends RegularSchedule implements Serializable {

    private static final long serialVersionUID = 20050226;
    
    /*
     *  (non-Javadoc)
     * @see org.treesched.RegularSchedule#next(java.util.Date)
     */
    public Date next(Date from) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTime(from);
        calendar.add(Calendar.DATE, 7);
        return calendar.getTime();
    }
}
