Added extra comments to the Coffeescript to describe the calculations that are going on

This commit is contained in:
Mark Abbott 2012-03-04 17:01:09 +00:00
parent 6be7b1904c
commit 6fb708acea

View File

@ -296,10 +296,13 @@ class Morris.Line
year = parseInt(p[1], 10);
y1 = new Date(year, 0, 1);
y2 = new Date(year+1, 0, 1);
# first thursday in year (ISO 8601 standard)
if y1.getDay() isnt 4
y1.setMonth(0, 1 + ((4 - y1.getDay()) + 7) % 7);
# first thursday in following year
if y2.getDay() isnt 4
y2.setMonth(0, 1 + ((4 - y2.getDay()) + 7) % 7);
# Number of weeks between thursdays
weeks = 1 + Math.ceil((y2 - y1) / 604800000);
parseInt(p[1], 10) + (parseInt(p[2], 10) - 1) / weeks;
else if n