You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by se...@apache.org on 2018/01/31 16:27:57 UTC
svn commit: r1822813 - /comdev/reporter.apache.org/trunk/site/js/render.js
Author: sebb
Date: Wed Jan 31 16:27:57 2018
New Revision: 1822813
URL: http://svn.apache.org/viewvc?rev=1822813&view=rev
Log:
COMDEV-257 - Reporter does not calculate next report date correctly at month end
Modified:
comdev/reporter.apache.org/trunk/site/js/render.js
Modified: comdev/reporter.apache.org/trunk/site/js/render.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/js/render.js?rev=1822813&r1=1822812&r2=1822813&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/js/render.js (original)
+++ comdev/reporter.apache.org/trunk/site/js/render.js Wed Jan 31 16:27:57 2018
@@ -58,19 +58,13 @@ function makeSelect(name, arr) {
return sel
}
+// return all the Wednesdays in the month
function getWednesdays(mo, y) {
var d = new Date();
- if (mo) {
- d.setMonth(mo);
- }
- if (y) {
- d.setFullYear(y, d.getMonth(), d.getDate())
- }
+ d.setFullYear(y, mo, 1)
var month = d.getMonth(),
wednesdays = [];
- d.setDate(1);
-
// Get the first Wednesday (day 3 of week) in the month
while (d.getDay() !== 3) {
d.setDate(d.getDate() + 1);
@@ -133,23 +127,26 @@ function setReportDate(json, x) {
}
}
+ // Find the 3rd Wed in each month for this year
+ var this_year = today.getFullYear();
// Check the months in order, so it does not matter if the data is unordered
for (var x in m) {
for (i in rm) {
if (m[x] == rm[i]) {
- dates.push(getWednesdays(x)[2])
+ dates.push(getWednesdays(x, this_year)[2])
}
}
}
+ // Also for next year to allow for year-end wrap-round
// cannot combine with the code above because that would destroy the order
- var ny = today.getFullYear() + 1;
for (x in m) {
for (i in rm) {
if (m[x] == rm[i]) {
- dates.push(getWednesdays(x, ny)[2])
+ dates.push(getWednesdays(x, this_year+1)[2])
}
}
}
+ // find the first Wed that has not been reached
var nextdate = dates[0];
while (nextdate < today) {
nextdate = dates.shift();