Search in sources :

Example 76 with DateTimeUnit

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

the class PersianCalendarTest method testMinusWeeks.

@Test
void testMinusWeeks() {
    DateTimeUnit dateTimeUnit = new DateTimeUnit(1382, 1, 10);
    DateTimeUnit testDateTimeUnit = calendar.minusWeeks(dateTimeUnit, 2);
    assertEquals(1381, testDateTimeUnit.getYear());
    assertEquals(12, testDateTimeUnit.getMonth());
    assertEquals(25, testDateTimeUnit.getDay());
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) Test(org.junit.jupiter.api.Test)

Example 77 with DateTimeUnit

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

the class PersianCalendarTest method testMinusDays.

@Test
void testMinusDays() {
    DateTimeUnit dateTimeUnit = new DateTimeUnit(1371, 1, 1);
    DateTimeUnit testDateTimeUnit = calendar.minusDays(dateTimeUnit, 1);
    assertEquals(1370, testDateTimeUnit.getYear());
    assertEquals(12, testDateTimeUnit.getMonth());
    assertEquals(30, testDateTimeUnit.getDay());
    testDateTimeUnit = calendar.minusDays(dateTimeUnit, 366);
    assertEquals(1370, testDateTimeUnit.getYear());
    assertEquals(1, testDateTimeUnit.getMonth());
    assertEquals(1, testDateTimeUnit.getDay());
    dateTimeUnit = new DateTimeUnit(1371, 7, 1);
    testDateTimeUnit = calendar.minusDays(dateTimeUnit, 1);
    assertEquals(1371, testDateTimeUnit.getYear());
    assertEquals(6, testDateTimeUnit.getMonth());
    assertEquals(31, testDateTimeUnit.getDay());
    dateTimeUnit = new DateTimeUnit(1371, 8, 1);
    testDateTimeUnit = calendar.minusDays(dateTimeUnit, 1);
    assertEquals(1371, testDateTimeUnit.getYear());
    assertEquals(7, testDateTimeUnit.getMonth());
    assertEquals(30, testDateTimeUnit.getDay());
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) Test(org.junit.jupiter.api.Test)

Example 78 with DateTimeUnit

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

the class PersianCalendarTest method testToInterval.

@Test
void testToInterval() {
    DateTimeUnit start = new DateTimeUnit(1373, 6, 1, java.util.Calendar.FRIDAY);
    DateInterval interval = calendar.toInterval(start, DateIntervalType.ISO8601_DAY, 0, 10);
    assertEquals(1994, interval.getTo().getYear());
    assertEquals(9, interval.getTo().getMonth());
    assertEquals(2, interval.getTo().getDay());
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DateInterval(org.hisp.dhis.calendar.DateInterval) Test(org.junit.jupiter.api.Test)

Example 79 with DateTimeUnit

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

the class NepaliCalendarTest method testFromIso.

@Test
void testFromIso() {
    Assertions.assertEquals(new DateTimeUnit(2071, 1, 1, false), calendar.fromIso(new DateTimeUnit(2014, 4, 14, true)));
    Assertions.assertEquals(new DateTimeUnit(2071, 1, 1, false), calendar.fromIso(2014, 4, 14));
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) Test(org.junit.jupiter.api.Test)

Example 80 with DateTimeUnit

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

the class EthiopianCalendarTest method testMinusDays.

@Test
void testMinusDays() {
    DateTimeUnit dateTimeUnit = new DateTimeUnit(2007, 1, 1);
    DateTimeUnit testDateTimeUnit = calendar.minusDays(dateTimeUnit, 2);
    assertEquals(2006, testDateTimeUnit.getYear());
    assertEquals(12, testDateTimeUnit.getMonth());
    assertEquals(29, testDateTimeUnit.getDay());
}
Also used : DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) Test(org.junit.jupiter.api.Test)

Aggregations

DateTimeUnit (org.hisp.dhis.calendar.DateTimeUnit)98 Calendar (org.hisp.dhis.calendar.Calendar)23 Test (org.junit.jupiter.api.Test)17 Date (java.util.Date)15 DateInterval (org.hisp.dhis.calendar.DateInterval)10 Period (org.hisp.dhis.period.Period)6 DateTime (org.joda.time.DateTime)5 LocalDate (java.time.LocalDate)4 DimensionalObject (org.hisp.dhis.common.DimensionalObject)4 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)4 ArrayList (java.util.ArrayList)3 WeekFields (java.time.temporal.WeekFields)2 HashMap (java.util.HashMap)2 Matcher (java.util.regex.Matcher)2 InvalidCalendarParametersException (org.hisp.dhis.calendar.exception.InvalidCalendarParametersException)2 DataDimensionalItemObject (org.hisp.dhis.common.DataDimensionalItemObject)2 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)2 DataElement (org.hisp.dhis.dataelement.DataElement)2 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)2 DateUtils.getMediumDateString (org.hisp.dhis.util.DateUtils.getMediumDateString)2