← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15029: support Daily periods in js generator

 

------------------------------------------------------------
revno: 15029
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 21:49:05 +0545
message:
  support Daily periods in js generator
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	2014-04-27 15:55:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js	2014-04-27 16:04:05 +0000
@@ -76,6 +76,29 @@
   return periods;
 };
 
+dhis2.period.generateDailyPeriods = function( cal, offset ) {
+  var year = cal.today().year() - offset;
+
+  var periods = [];
+
+  var startDate = cal.newDate(year, 1, 1);
+
+  for( var day = 1; day <= cal.daysInYear(year); day++ ) {
+    var period = {};
+    period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+    period['endDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+    period['name'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+    period['id'] = 'Daily_' + period['startDate'];
+    period['iso'] = startDate.formatDate("yyyymmdd");
+
+    periods.push(period);
+
+    startDate.add(1, 'd');
+  }
+
+  return periods;
+};
+
 dhis2.period.generateBiMonthlyPeriods = function( cal, offset ) {
   var year = cal.today().year() - offset;