← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19909: ignore the 13th month for Ethiopian calendar.

 

------------------------------------------------------------
revno: 19909
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-08-31 11:53:43 +0200
message:
  ignore the 13th month for Ethiopian calendar.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js


--
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-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2015-06-10 20:22:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2015-08-31 09:53:43 +0000
@@ -596,7 +596,7 @@
     var year = offset + this.calendar.today().year();
     var periods = [];
     
-    for( var month = 1; month <= this.calendar.monthsInYear(year); month++ ) {
+    for( var month = 1; month <= getHMISMonthsInYear(this.calendar, year); month++ ) {
       var startDate = this.calendar.newDate(year, month, 1);
       var endDate = this.calendar.newDate(startDate).set(startDate.daysInMonth(month), 'd');
 
@@ -685,7 +685,7 @@
     var year = offset + this.calendar.today().year();
     var periods = [];
 
-    for( var month = 1, idx = 1; month <= this.calendar.monthsInYear(year); month += 3, idx++ ) {
+    for( var month = 1, idx = 1; month <= getHMISMonthsInYear(this.calendar, year); month += 3, idx++ ) {
       var startDate = this.calendar.newDate(year, month, 1);
       var endDate = this.calendar.newDate(startDate).set(month + 2, 'm');
       endDate.set(endDate.daysInMonth(month + 2), 'd');
@@ -976,3 +976,17 @@
 };
 
 dhis2.period.FinancialOctoberGenerator.prototype = Object.create(dhis2.period.FinancialBaseGenerator.prototype);
+
+/**
+ * Convenience method to get DHIS2/HMIS months in a year 
+ */
+function getHMISMonthsInYear( calendar, year ) {
+	
+	var monthsInYear = calendar.monthsInYear(year);
+	
+	if( $.calendars.calendars.ethiopian && calendar instanceof $.calendars.calendars.ethiopian ){
+		monthsInYear = monthsInYear - 1;
+	}
+  	
+  	return monthsInYear;
+}