nl.hsac.fitnesse.symbols.WeekDaysFromToday Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hsac-fitnesse-plugin Show documentation
Show all versions of hsac-fitnesse-plugin Show documentation
Plugin to add features to a FitNesse installation
package nl.hsac.fitnesse.symbols;
import fitnesse.wikitext.parser.Today;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* Our version of !today, that allows us to specify working days instead of days,
* i.e. no Saturdays and Sundays
* Usage: !weekDaysFromToday [(format)] [+|-increment]
*/
public class WeekDaysFromToday extends Today {
public WeekDaysFromToday() {
super("WeekDaysFromToday", "!weekDaysFromToday", Calendar.DATE);
}
@Override
protected void addIncrement(GregorianCalendar cal, int numWeekDays) {
int numDays = Math.abs(numWeekDays);
int dateAddition = numWeekDays < 0 ? -1 : 1;
for (int i = 0; i < numDays; i++) {
cal.add(Calendar.DATE, dateAddition);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
if (dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY) {
i--;
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy