use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class EthiopianCalendarTest method testGenerateQuarterlyPeriods.
@Test
public void testGenerateQuarterlyPeriods() {
Date startDate = new Cal(1975, 1, 1, true).time();
Date endDate = new Cal(2025, 1, 2, true).time();
List<Period> quarters = new QuarterlyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(201, quarters.size());
}
use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class PersianCalendarTest method testGenerateMonthlyPeriods.
@Test
public void testGenerateMonthlyPeriods() {
Date startDate = new Cal(1997, 1, 1, true).time();
Date endDate = new Cal(1998, 1, 1, true).time();
List<Period> monthly = new MonthlyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(13, monthly.size());
}
use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class EthiopianCalendarTest method testGenerateDailyPeriods.
@Test
public void testGenerateDailyPeriods() {
Date startDate = new Cal(1975, 1, 1, true).time();
Date endDate = new Cal(2025, 1, 2, true).time();
List<Period> days = new DailyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(18001, days.size());
}
use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class DatePeriodResourceTable method getPopulateTempTableContent.
@Override
public Optional<List<Object[]>> getPopulateTempTableContent() {
List<PeriodType> periodTypes = PeriodType.getAvailablePeriodTypes();
List<Object[]> batchArgs = new ArrayList<>();
//TODO
Date startDate = new Cal(1975, 1, 1, true).time();
Date endDate = new Cal(2025, 1, 1, true).time();
List<Period> days = new UniqueArrayList<>(new DailyPeriodType().generatePeriods(startDate, endDate));
Calendar calendar = PeriodType.getCalendar();
for (Period day : days) {
List<Object> values = new ArrayList<>();
values.add(day.getStartDate());
for (PeriodType periodType : periodTypes) {
values.add(periodType.createPeriod(day.getStartDate(), calendar).getIsoDate());
}
batchArgs.add(values.toArray());
}
return Optional.of(batchArgs);
}
use of org.hisp.dhis.period.Cal in project dhis2-core by dhis2.
the class EthiopianCalendarTest method testGenerateMonthlyPeriods.
@Test
public void testGenerateMonthlyPeriods() {
Date startDate = new Cal(1975, 1, 1, true).time();
Date endDate = new Cal(2025, 1, 2, true).time();
List<Period> monthly = new MonthlyPeriodType().generatePeriods(calendar, startDate, endDate);
assertEquals(601, monthly.size());
}
Aggregations