Search in sources :

Example 1 with DateInterval

use of org.hisp.dhis.calendar.DateInterval in project dhis2-core by dhis2.

the class PersianCalendar method toDayIsoInterval.

private DateInterval toDayIsoInterval(DateTimeUnit dateTimeUnit, int offset, int length) {
    DateTimeUnit from = new DateTimeUnit(dateTimeUnit);
    if (offset >= 0) {
        from = plusDays(from, offset);
    } else if (offset < 0) {
        from = minusDays(from, -offset);
    }
    DateTimeUnit to = new DateTimeUnit(from);
    to = plusDays(to, length);
    from = toIso(from);
    to = toIso(to);
    return new DateInterval(from, to, DateIntervalType.ISO8601_DAY);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DateInterval(org.hisp.dhis.calendar.DateInterval)

Example 2 with DateInterval

use of org.hisp.dhis.calendar.DateInterval in project dhis2-core by dhis2.

the class PersianCalendar method toYearIsoInterval.

private DateInterval toYearIsoInterval(DateTimeUnit dateTimeUnit, int offset, int length) {
    DateTimeUnit from = new DateTimeUnit(dateTimeUnit);
    if (offset > 0) {
        from = plusYears(from, offset);
    } else if (offset < 0) {
        from = minusYears(from, -offset);
    }
    DateTimeUnit to = new DateTimeUnit(from);
    to = plusYears(to, length);
    to = minusDays(to, length);
    from = toIso(from);
    to = toIso(to);
    return new DateInterval(from, to, DateIntervalType.ISO8601_YEAR);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DateInterval(org.hisp.dhis.calendar.DateInterval)

Example 3 with DateInterval

use of org.hisp.dhis.calendar.DateInterval in project dhis2-core by dhis2.

the class PersianCalendar method toWeekIsoInterval.

private DateInterval toWeekIsoInterval(DateTimeUnit dateTimeUnit, int offset, int length) {
    DateTimeUnit from = new DateTimeUnit(dateTimeUnit);
    if (offset > 0) {
        from = plusWeeks(from, offset);
    } else if (offset < 0) {
        from = minusWeeks(from, -offset);
    }
    DateTimeUnit to = new DateTimeUnit(from);
    to = plusWeeks(to, length);
    to = minusDays(to, 1);
    from = toIso(from);
    to = toIso(to);
    return new DateInterval(from, to, DateIntervalType.ISO8601_WEEK);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DateInterval(org.hisp.dhis.calendar.DateInterval)

Example 4 with DateInterval

use of org.hisp.dhis.calendar.DateInterval in project dhis2-core by dhis2.

the class PersianCalendar method toMonthIsoInterval.

private DateInterval toMonthIsoInterval(DateTimeUnit dateTimeUnit, int offset, int length) {
    DateTimeUnit from = new DateTimeUnit(dateTimeUnit);
    if (offset > 0) {
        from = plusMonths(from, offset);
    } else if (offset < 0) {
        from = minusMonths(from, -offset);
    }
    DateTimeUnit to = new DateTimeUnit(from);
    to = plusMonths(to, length);
    to = minusDays(to, 1);
    from = toIso(from);
    to = toIso(to);
    return new DateInterval(from, to, DateIntervalType.ISO8601_MONTH);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DateInterval(org.hisp.dhis.calendar.DateInterval)

Example 5 with DateInterval

use of org.hisp.dhis.calendar.DateInterval in project dhis2-core by dhis2.

the class NepaliCalendar method toMonthIsoInterval.

private DateInterval toMonthIsoInterval(DateTimeUnit dateTimeUnit, int offset, int length) {
    DateTimeUnit from = new DateTimeUnit(dateTimeUnit);
    if (offset > 0) {
        from = plusMonths(from, offset);
    } else if (offset < 0) {
        from = minusMonths(from, -offset);
    }
    DateTimeUnit to = new DateTimeUnit(from);
    to = plusMonths(to, length);
    to = minusDays(to, 1);
    from = toIso(from);
    to = toIso(to);
    return new DateInterval(from, to, DateIntervalType.ISO8601_MONTH);
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DateInterval(org.hisp.dhis.calendar.DateInterval)

Aggregations

DateInterval (org.hisp.dhis.calendar.DateInterval)10 DateTimeUnit (org.hisp.dhis.calendar.DateTimeUnit)9 ArrayList (java.util.ArrayList)1 Calendar (org.hisp.dhis.calendar.Calendar)1 Test (org.junit.Test)1