← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21931: Added getDateAfterOffsetDays service to get the date after a given number of offset days.

 

------------------------------------------------------------
revno: 21931
committer: jijukjose <jijukjose@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-02-10 11:15:25 +0100
message:
  Added getDateAfterOffsetDays service to get the date after a given number of offset days.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.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.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2016-02-09 10:48:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2016-02-10 10:15:25 +0000
@@ -221,6 +221,16 @@
                 var calendarSetting = CalendarService.getSetting();
                 dateValue = moment(dateValue, 'YYYY-MM-DD')._d;
                 return $filter('date')(dateValue, calendarSetting.keyDateFormat);
+            },
+            getDateAfterOffsetDays: function (offSetDays) {
+                var date = new Date();
+                date.setDate(date.getDate()+offSetDays);
+                var calendarSetting = CalendarService.getSetting();
+                var tdy = $.calendars.instance(calendarSetting.keyCalendar).fromJSDate(date);
+                var dateAfterOffset = moment(tdy._year + '-' + tdy._month + '-' + tdy._day, 'YYYY-MM-DD')._d;
+                dateAfterOffset = Date.parse(dateAfterOffset);
+                dateAfterOffset = $filter('date')(dateAfterOffset, calendarSetting.keyDateFormat);
+                return dateAfterOffset;
             }
         };
     })