dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #42402
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21683: applied js weekly generator simplification patch from TW
------------------------------------------------------------
revno: 21683
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2016-01-11 10:02:31 +0700
message:
applied js weekly generator simplification patch from TW
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 2016-01-08 03:08:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.period.js 2016-01-11 03:02:31 +0000
@@ -540,22 +540,8 @@
var year = offset + this.calendar.today().year();
var periods = [];
- var startDate = this.calendar.newDate(year, 1, 1);
- var day = startDate.dayOfWeek();
-
- if( day == 0 ) // Sunday (0), forward to Monday
- {
- startDate.add(1, 'd');
- }
- else if( day <= 4 ) // Monday - Thursday, rewind to Monday
- {
- startDate.add(( ( day - 1 ) * -1 ), 'd');
- }
- else
- // Friday - Saturday, forward to Monday
- {
- startDate.add(8 - day, 'd');
- }
+ var startDate = this.calendar.newDate(year, 1, 4); // first ISO week of the year always contains 4th January
+ startDate.add(-(startDate.dayOfWeek() - 1), 'd'); // rewind to start of week, might cross year boundary
// no reliable way to figure out number of weeks in a year (can differ in different calendars)
// goes up to 200, but break when week is back to 1