use of com.alexstyl.specialdates.date.TimePeriod in project Memento-Calendar by alexstyl.
the class BankHolidayProvider method calculateBankHolidaysBetween.
public List<BankHoliday> calculateBankHolidaysBetween(TimePeriod timePeriod) {
if (isWithinTheSameYear(timePeriod)) {
return calculateBankHolidaysFor(timePeriod);
} else {
ArrayList<BankHoliday> allBankholidays = new ArrayList<>();
TimePeriod firstHalf = getfirstHalfOf(timePeriod);
List<BankHoliday> firstHalfBankHolidays = calculateBankHolidaysFor(firstHalf);
allBankholidays.addAll(firstHalfBankHolidays);
TimePeriod secondHalf = getSecondHalfOf(timePeriod);
List<BankHoliday> secondHalfBankHolidays = calculateBankHolidaysFor(secondHalf);
allBankholidays.addAll(secondHalfBankHolidays);
return allBankholidays;
}
}
use of com.alexstyl.specialdates.date.TimePeriod in project Memento-Calendar by alexstyl.
the class TimePeriodTest method dateOutsideOfPeriod.
@Test
public void dateOutsideOfPeriod() {
TimePeriod range = TimePeriod.Companion.between(Date.Companion.startOfYear(2016), Date.Companion.startOfYear(2017));
assertThat(range.containsDate(Date.Companion.on(1, FEBRUARY, 1990))).isFalse();
}
use of com.alexstyl.specialdates.date.TimePeriod in project Memento-Calendar by alexstyl.
the class TimePeriodTest method dateBetweenPeriod.
@Test
public void dateBetweenPeriod() {
TimePeriod range = TimePeriod.Companion.between(Date.Companion.startOfYear(2016), Date.Companion.startOfYear(2017));
assertThat(range.containsDate(Date.Companion.on(1, FEBRUARY, 2016))).isTrue();
}
use of com.alexstyl.specialdates.date.TimePeriod in project Memento-Calendar by alexstyl.
the class PeopleEventsSearch method searchForContacts.
List<ContactWithEvents> searchForContacts(String searchQuery, int counter) {
if (counter <= 0) {
return new ArrayList<>();
}
searchQuery = searchQuery.trim();
HashMapList<Contact, ContactEvent> events = new HashMapList<>();
TimePeriod between = TimePeriod.Companion.aYearFromNow();
List<ContactEvent> contactEventsOnDate = peopleEventsProvider.fetchEventsBetween(between);
int size = 0;
for (ContactEvent contactEvent : contactEventsOnDate) {
Contact contact = contactEvent.getContact();
if (nameMatcher.match(contact.getDisplayName(), searchQuery)) {
events.addValue(contact, contactEvent);
size++;
}
if (size >= counter) {
break;
}
}
List<ContactWithEvents> contactWithEvents = new ArrayList<>();
for (Contact contact : events.keys()) {
List<ContactEvent> list = events.get(contact);
contactWithEvents.add(new ContactWithEvents(contact, list));
}
return contactWithEvents;
}
Aggregations