use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class NepaliCalendar method plusMonths.
@Override
public DateTimeUnit plusMonths(DateTimeUnit dateTimeUnit, int months) {
if (months < 0) {
return minusMonths(dateTimeUnit, Math.abs(months));
}
DateTimeUnit result = new DateTimeUnit(dateTimeUnit);
while (months != 0) {
result.setMonth(result.getMonth() + 1);
if (result.getMonth() > monthsInYear()) {
result.setMonth(1);
result.setYear(result.getYear() + 1);
}
months--;
}
updateDateUnit(result);
return result;
}
use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class NepaliCalendar method minusYears.
@Override
public DateTimeUnit minusYears(DateTimeUnit dateTimeUnit, int years) {
DateTimeUnit result = new DateTimeUnit(dateTimeUnit.getYear() - years, dateTimeUnit.getMonth(), dateTimeUnit.getDay(), dateTimeUnit.getDayOfWeek());
updateDateUnit(result);
return result;
}
use of org.hisp.dhis.calendar.DateTimeUnit 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);
}
use of org.hisp.dhis.calendar.DateTimeUnit in project dhis2-core by dhis2.
the class PersianCalendar method plusYears.
@Override
public DateTimeUnit plusYears(DateTimeUnit dateTimeUnit, int years) {
DateTimeUnit result = new DateTimeUnit(dateTimeUnit.getYear() + years, dateTimeUnit.getMonth(), dateTimeUnit.getDay(), dateTimeUnit.getDayOfWeek());
updateDateUnit(result);
return result;
}
use of org.hisp.dhis.calendar.DateTimeUnit 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);
}
Aggregations