dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29684
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15028: support SixMonthlyApril periods in js generator
------------------------------------------------------------
revno: 15028
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-04-27 21:40:29 +0545
message:
support SixMonthlyApril 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:01:39 +0000
+++ 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
@@ -136,7 +136,7 @@
period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
period['name'] = startDate.formatDate("MM") + '-' + endDate.formatDate('MM') + ' ' + year;
period['id'] = 'SixMonthly_' + period['startDate'];
- period['iso'] = startDate.formatDate("yyyy") + 'S' + 1;
+ period['iso'] = startDate.formatDate("yyyy") + 'S1';
periods.push(period);
@@ -149,7 +149,41 @@
period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
period['name'] = startDate.formatDate("MM") + '-' + endDate.formatDate('MM') + ' ' + year;
period['id'] = 'SixMonthly_' + period['startDate'];
- period['iso'] = startDate.formatDate("yyyy") + 'S' + 2;
+ period['iso'] = startDate.formatDate("yyyy") + 'S2';
+
+ periods.push(period);
+
+ return periods;
+};
+
+dhis2.period.generateSixMonthlyAprilPeriods = function( cal, offset ) {
+ var year = cal.today().year() - offset;
+
+ var periods = [];
+
+ var startDate = cal.newDate(year, 4, 1);
+ var endDate = cal.newDate(startDate).set(9, 'm');
+ endDate.set(endDate.daysInMonth(9), 'd');
+
+ var period = {};
+ period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+ period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
+ period['name'] = startDate.formatDate("MM") + ' - ' + endDate.formatDate('MM') + ' ' + year;
+ period['id'] = 'SixMonthlyApril_' + period['startDate'];
+ period['iso'] = startDate.formatDate("yyyy") + 'AprilS1';
+
+ periods.push(period);
+
+ startDate = cal.newDate(year, 10, 1);
+ endDate = cal.newDate(startDate).set(startDate.year() + 1, 'y').set(2, 'm');
+ endDate.set(endDate.daysInMonth(endDate.month()), 'd');
+
+ period = {};
+ period['startDate'] = startDate.formatDate(dhis2.period.DATE_FORMAT);
+ period['endDate'] = endDate.formatDate(dhis2.period.DATE_FORMAT);
+ period['name'] = startDate.formatDate("MM yyyy") + ' - ' + endDate.formatDate('MM yyyy');
+ period['id'] = 'SixMonthlyApril_' + period['startDate'];
+ period['iso'] = startDate.formatDate("yyyy") + 'AprilS2';
periods.push(period);