← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15008: Adds type information to DateInterval.

 

------------------------------------------------------------
revno: 15008
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 08:15:29 +0545
message:
  Adds type information to DateInterval.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java	2014-04-27 02:25:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/ChronologyBasedCalendar.java	2014-04-27 02:30:29 +0000
@@ -85,7 +85,7 @@
         from.setDayOfWeek( isoWeekday( from ) );
         to.setDayOfWeek( isoWeekday( to ) );
 
-        return new DateInterval( from, to );
+        return new DateInterval( from, to, DateInterval.DateIntervalType.ISO8601_YEAR );
     }
 
     private DateInterval toMonthIsoInterval( DateUnit dateUnit )
@@ -96,7 +96,7 @@
         from.setDayOfWeek( isoWeekday( from ) );
         to.setDayOfWeek( isoWeekday( to ) );
 
-        return new DateInterval( from, to );
+        return new DateInterval( from, to, DateInterval.DateIntervalType.ISO8601_MONTH );
     }
 
     private DateInterval toWeekIsoInterval( DateUnit dateUnit )
@@ -106,7 +106,7 @@
         DateTime from = dateTime.weekOfWeekyear().toInterval().getStart();
         DateTime to = dateTime.weekOfWeekyear().toInterval().getEnd().minusDays( 1 );
 
-        return new DateInterval( DateUnit.fromDateTime( from ), DateUnit.fromDateTime( to ) );
+        return new DateInterval( DateUnit.fromDateTime( from ), DateUnit.fromDateTime( to ), DateInterval.DateIntervalType.ISO8601_WEEK );
     }
 
     @Override

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java	2014-04-27 02:27:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/DateInterval.java	2014-04-27 02:30:29 +0000
@@ -59,12 +59,24 @@
     @NotNull
     private final DateUnit to;
 
+    /**
+     * Interval type this interval represents.
+     */
+    private DateIntervalType type;
+
     public DateInterval( DateUnit from, DateUnit to )
     {
         this.from = from;
         this.to = to;
     }
 
+    public DateInterval( DateUnit from, DateUnit to, DateIntervalType type )
+    {
+        this.from = from;
+        this.to = to;
+        this.type = type;
+    }
+
     public DateUnit getFrom()
     {
         return from;
@@ -75,11 +87,18 @@
         return to;
     }
 
-    @Override public String toString()
+    public DateIntervalType getType()
+    {
+        return type;
+    }
+
+    @Override
+    public String toString()
     {
         return "DateInterval{" +
             "from=" + from +
             ", to=" + to +
+            ", type=" + type +
             '}';
     }
 }