=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java 2014-04-25 12:25:39 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/calendar/Calendar.java 2014-04-26 06:11:00 +0000 @@ -29,39 +29,134 @@ */ /** + * Generic interface for representing a Calendar. * @author Morten Olav Hansen + * @see DateUnit + * @see DateInterval */ public interface Calendar { + /** + * Name of this calendar. + * @return Name of calendar. + */ String name(); + /** + * Convert local calendar to an ISO 8601 DateUnit. + * @param year Local year + * @param month Local month + * @param day Local month + * @return DateUnit representing local date in ISO 8601 + * @see http://en.wikipedia.org/wiki/ISO_8601 + */ DateUnit toIso( int year, int month, int day ); + /** + * Convert local calendar to an ISO 8601 DateUnit. + * @param dateUnit DateUnit representing local year, month, day + * @return DateUnit representing local date in ISO 8601 + * @see http://en.wikipedia.org/wiki/ISO_8601 + */ DateUnit toIso( DateUnit dateUnit ); + /** + * Convert from local to ISO 8601 DateUnit. + * @param year ISO 8601 year + * @param month ISO 8601 month + * @param day ISO 8601 month + * @return DateUnit representing ISO 8601 in local + * @see http://en.wikipedia.org/wiki/ISO_8601 + */ DateUnit fromIso( int year, int month, int day ); + /** + * Convert from local to ISO 8601 DateUnit. + * @param dateUnit DateUnit representing ISO 8601 year, month, day + * @return DateUnit representing ISO 8601 in local + * @see http://en.wikipedia.org/wiki/ISO_8601 + */ DateUnit fromIso( DateUnit dateUnit ); + /** + * Returns this local year as a ISO 8601 interval + * @param year Local year + * @return ISO 8601 interval for year + * @see http://en.wikipedia.org/wiki/ISO_8601 + */ DateInterval toIsoInterval( int year ); + /** + * Returns this local year/month as a ISO 8601 interval + * @param year Local year + * @param month Local month + * @return ISO 8601 interval for year/month + * @see http://en.wikipedia.org/wiki/ISO_8601 + */ DateInterval toIsoInterval( int year, int month ); + /** + * Returns current date as local DateUnit + * @return Today date as local DateUnit + */ DateUnit today(); + /** + * Returns the number of months in a calendar year. + * @return Number of months in a year + */ int monthsInYear(); + /** + * Returns the number of days in a calendar week. + * @return Number of days in a week + */ int daysInWeek(); + /** + * Returns the number of days in a calendar year. + * @return Number of days in this calendar year + */ int daysInYear( int year ); + /** + * Returns the number of days in a calendar year/month. + * @return Number of days in this calendar year/month + */ int daysInMonth( int year, int month ); + /** + * Returns week number using local DateUnit, week number is calculated based on + * ISO 8601 week numbers + * @param dateUnit DateUnit representing local year, month, day + * @return Week number + * @see http://en.wikipedia.org/wiki/ISO_8601 + * @see http://en.wikipedia.org/wiki/ISO_week_date + */ int isoWeek( DateUnit dateUnit ); + /** + * Returns week number using local DateUnit, week number is calculated based on local calendar. + * @param dateUnit DateUnit representing local year, month, day + * @return Week number + */ int week( DateUnit dateUnit ); + /** + * Returns the ISO 8601 weekday for this local DateUnit, using ISO 8601 day numbering, + * 1=Monday => 7=Sunday. + * @param dateUnit DateUnit representing local year, month, day + * @return Weekday number + * @see http://en.wikipedia.org/wiki/ISO_8601 + * @see http://en.wikipedia.org/wiki/ISO_week_date + */ int isoWeekday( DateUnit dateUnit ); + /** + * Returns the local weekday for this local DateUnit, using ISO 8601 day numbering, + * 1=Monday => 7=Sunday. + * @param dateUnit DateUnit representing local year, month, day + * @return Weekday number + */ int weekday( DateUnit dateUnit ); }